![]() |
Alexey admin 7/28/2006 |
Bart, $conn1=mysql_connect(...); $strSQL = "insert into table1 (username,password) values ('".$userdata["username"]."','".$userdata["username"]."')"; mysql_query($strSQL,$conn1); mysql_close($conn1); |
B
|
bbanks author 7/28/2006 |
Bart, sure, it's possible. Open a new MySQL connection and execute SQL INSERT statement. Here is the sample code for Before register event:
[size=2] function BeforeRegister($userdata) { // Parameters: // $userdata - Array. // Each field on this form represented as pair //** Insert a record into another table **** $conn1=mysql_connect($host=[color="#ff00ff"]"[font="Courier"]); $strSQL = [color="#ff00ff"]"insert into My_Table (username,user_password) values ('".$userdata[; mysql_query($strSQL,$conn1); mysql_close($conn1); return true; // return true [color=#0000ff]if you like to proceed with registration // return false in other case }
|
![]() |
Alexey admin 7/31/2006 |
Bart, |
B
|
bbanks author 7/31/2006 |
Ok, here is what I have now. [size=2] function BeforeRegister($userdata) { // Parameters: // $userdata - Array. // Each field on this form represented as pair //** Insert a record into another table **** $conn1 = mysql_connect([color="#ff00ff"]'MyServer:3306', ); $strSQL = [color="#ff00ff"]"insert into My_Table ('username','user_password') values ('".$userdata[; mysql_query($strSQL,$conn1); [color=#0000ff] if (!$conn1) { die( . mysql_error()); } [color=#0000ff] echo ; mysql_close($conn1); return true; // return true [color=#0000ff]if you like to proceed with registration // return false in other case }
|
![]() |
Alexey admin 8/1/2006 |
Bart, .... $conn1 = mysql_connect('MyServer:3306', 'MyUsername', 'MyPassword'); mysql_select_db('MyDatabase', $conn1); $strSQL = "insert into My_Table ('username','user_password') values ('".$userdata['username']."','".$userdata['pass']."')"; mysql_query($strSQL,$conn1); ... |
B
|
bbanks author 8/1/2006 |
Great Thank you very much that works now. |
![]() |
Alexey admin 8/2/2006 |
Bart, $strSQL = "insert into My_Table ('username','user_password') values ('".$userdata['username']."',MD5('".$userdata['pass']."'))"; |
B
|
bbanks author 8/7/2006 |
Bart, use MD5 MySQL function to encrypt passwords. I.e.
$sql = "SELECT MAX(user_id) AS total FROM " . MyTable; $user_id = $row['total'] + 1; |
J
|
Jane 8/8/2006 |
Bart, global $conn_new; $sql = "SELECT MAX(user_id) AS total FROM My_Table"; $rs = db_query($sql,$conn_new); $data = db_fetch_array($rs); $user_id = $data["total"] + 1; ... $strSQL = "insert into My_Table ('userid','username','user_password') values (".$user_id.",'".$userdata['username']."',MD5('".$userdata['pass']."'))";
|
B
|
bbanks author 8/8/2006 |
This is what I have from the info you sent. The table actually starts at user_id -1 and skips 0 and 1 then goes up to 36. Before I inserted your code it was adding one record with user_id 0 but wouldn't add another record after that. Now with what I have below it skips 0 and adds one record with the user_id 1 but will not add another record after that. //** Insert a record into another table **** $conn1 = mysql_connect(); mysql_select_db([color=#ff00ff]'MyDatabase', $conn1); $sql = ; $rs = db_query($sql,$conn1); $user_id = $data[[color="#ff00ff"]"total"] + ; $strSQL = [color="#ff00ff"]"insert into MyTable (user_id, username, user_email, user_password) values (".$user_id.; mysql_query($strSQL,$conn1); mysql_close($conn1); return true; // return true [color=#0000ff]if you like to proceed with registration // return false in other case } |
B
|
bbanks author 8/8/2006 |
Ok I got it now. |