Hi, I’m not sure why this not working, I’m trying to create signup form with email confirmation, they are two different table name in mysql one is called temps_users and other use us users.
When new member signed up it sending all of the new member profile to the temps_user tables, until member verify email by email conformation, if confirm then it will transfer the profile from temps_users to users tables and delete profile in temps_users.
So far I have done that and works great when transfer from temps_users to users, but after transfer the data profile from temps_users to users, meaning member are activity, I want to redirect to login.php page for them to login in before get into the member home page, the problem I have is that is not redirect to login.php page and delete profile from temps_users.
Please see the code area where it said $result2=mysql_query($sql); (see in bold area)
From that line is suppost to be redirect to login.php page and delete profile from temps_users.
Is not working what did I missed!
<?php
include('config.php');
// Passkey that got from link
$passkey=$_GET['passkey'];
$tbl_name1="temps_users";
// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM temps_users WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1);
// If successfully queried
if($result1){
// Count how many row has this passkey
$count=mysql_num_rows($result1);
// if found this passkey in our database, retrieve data from table "temp_members_db"
if($count==1){
$rows=mysql_fetch_array($result1);
$username=$rows['username'];
$first_name=$rows['first_name'];
$last_name=$rows['last_name'];
$email=$rows['email'];
$password=$rows['password'];
$type=$rows['type'];
// Insert data that retrieves from "temp_members_db" into table "registered_members"
$sql2=mysql_query("INSERT INTO users(username,password,email,type,first_name,last_name )VALUES('$username','$password','$email','$type','$first_name','$last_name' )");
$sql=mysql_query("SELECT uid FROM users WHERE username='$username'");
$row=mysql_fetch_array($sql);
$uid=$row['uid'];
$friend_query=mysql_query("INSERT INTO friends(friend_one,friend_two,role)VALUES('$uid','$uid','me')");
return $uid ;
[B]$result2=mysql_query($sql);[/B]
}
// if not found passkey, display message "Wrong Confirmation code"
else {
echo "Wrong Confirmation code";
}
// if successfully moved data from table"temp_members_db" to table "registered_members" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_members_db"
if($friend_query){
header("Location:login.php");
// Delete information of this user from table "temp_members_db" that has this passkey
$sql3="DELETE FROM temps_users WHERE confirm_code = '$passkey'";
$result3=mysql_query($sql3);
}
}
?>