I have two tables
I want to confirm values from user table and then insert it in registered_members table but the problem is .. values selected good from users table but inserted in registered_members with blank values Why??
<?
include('conf.php');
// Passkey that got from link
$passkey=$_GET['passkey'];
$tbl_name1="users";
// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1) or die ("error1") ;
// 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 "users"
if($count==1){
$rows=mysql_fetch_array($result1);
$username=$_POST['uname'];
$fname=$_POST['fname'];
$password=$_POST['password'];
$email=$_POST['email'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$tbl_name2="registered_members";
// Insert data that retrieves from "users" into table "registered_members"
$sql2=("INSERT INTO $tbl_name2 (uname,fname,password,email,age,gender)VALUES('$username','$fname','$password','$email','$age','$gender')");
$result2=mysql_query($sql2) or die ("error insert");
}
// if not found passkey, display message "Wrong Confirmation code"
else {
echo "Wrong Confirmation code";
}
// if successfully moved data from table"users" to table "registered_members" displays message "Your account has been activated" and don't forget to delete confirmation code from table "users"
if($result2){
echo "Your account has been activated";
// Delete information of this user from table "temp_members_db" that has this passkey
$sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'";
$result3=mysql_query($sql3);
}
}
?>
Because you are using $_POST instead of #rows
Change
$rows=mysql_fetch_array($result1);
$username=$_POST['uname'];
$fname=$_POST['fname'];
$password=$_POST['password'];
$email=$_POST['email'];
$age=$_POST['age'];
$gender=$_POST['gender'];
with
$rows=mysql_fetch_array($result1);
$username=$rows['uname'];
$fname=$rows['fname'];
$password=$rows['password'];
$email=$rows['email'];
$age=$rows['age'];
$gender=$rows['gender'];
Change $_POST
to $row
in all these lines:
$username=$_POST['uname'];
$fname=$_POST['fname'];
$password=$_POST['password'];
$email=$_POST['email'];
$age=$_POST['age'];
$gender=$_POST['gender'];
Because you are fetching the result in $row
as $rows=mysql_fetch_array($result1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.