Inserting into database
Posted: Mon Feb 27, 2006 7:20 pm
I am trying to insert values into two table in a database. I have my website and phpbb that have seperate user tables. When a user registers I want to add the same username, email and password to both tables so a user can register once for both features. Here is my code:
I have even temporarally commented another part of the code that will increment the userid of the max user id in the db then assign that value to user id and for now use 3 for user id and some nonsensicle value for session time. I did this just to see if I could get it to work in its most basic form but it doesnt work. Anyone know why I cant insert this info into the database. Do I have to insert something into all fields of the phpbb database which has many fields. Any help would be appreciated.
Code: Select all
$pass2 = $_POST['pass2'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$phone = $_POST['phone'];
$handle = $_POST['handle'];
$name = $_POST['name'];
if( checkemail($email) && $pass && alphanumericonly($handle) && ($pass==$pass2) )
{
require_once($home."mysqlinfo.php");
$query = "SELECT handle FROM users WHERE (handle='$handle')";
//for phpbb
//$sql = "SELECT MAX(user_id) AS total FROM phpbb_users";
//endphopbb
$checkhandle = mysql_query($query);
if(mysql_num_rows($checkhandle))
{teX("$handle already exists, please click your browser's back button and choose a different user name.","verify2");}
else
{
$im = $_POST['imname']."|".$_POST['imservice'];
include('i_aeskey.php'); //sets $AES_key variable
$query = "INSERT INTO `users` ( `email` , `name` , `phone` , `im` , `date` , `password` , `handle` )
VALUES ( '$email', '$name', '$phone', '$im', CURDATE( ) , AES_ENCRYPT('$pass','$AES_key'), '$handle' );";
//for phpbb
//$result = mysql_query($sql);
//$row = mysql_fetch_row($result);
//$user_id = $row(total) + 1;
$sql = "INSERT INTO `phpbb_users` ( 'user_id',`user_email` , `user_password` , `username`, 'user_session_time' )
VALUES ( '3','$email',AES_ENCRYPT('$pass','$AES_key'), '$handle','1234235315656' );";
$result2 = mysql_query($sql);
//end phpbb
$result = mysql_query($query);
if($result)
{teX("User $handle has been added.","verify2");}
else
{teX("Error. If problem persists please contact system administrator.","caution");}
//for phpbb
if($result2)
{teX("User $handle has been added.","verify2");}
else
{teX("Error. If problem persists please contact system administrator.","caution");}
//end phpbb