view user/uk/confirmation.php @ 60:05f29eb72283 default tip

review from DB not working???
author Charlie Root
date Sun, 09 Jun 2019 06:50:44 -0400
parents a67bf725e87b
children
line wrap: on
line source

<?PHP
include "db.php";  


// Passkey that got from link
$passkey=$_GET['passkey'];
$tbl_name1="temp_user";
$loc = 1;

// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
//echo $sql1;
$result1=mysqli_query($link,$sql1);

// If successfully queried
if($result1){

// Count how many row has this passkey
$count=mysqli_num_rows($result1);
//echo $count;
// if found this passkey in our database, retrieve data from table
if($count==1){

	$rows=mysqli_fetch_array($result1, MYSQLI_ASSOC);
	$email=$rows['Email'];
	$password=$rows['Password'];
	$fname=$rows['FirstName'];
	$sname=$rows['Surname'];

	$tbl_name2="user";

	// Insert data that retrieves from "temp_members_db" into table "registered_members"
	//$add = 'insert into user values (null,\'' . $email . '\',\'' . $password . '\');';
	$add="CALL addNewUser('$email', '$password', '$fname', '$sname', $loc)";

	//echo $add;
	$result2 = mysqli_query($link, $add);
}
// if not found passkey, display message
else {
echo "Invalid 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($result2){
	//Would prefer to create the cookie here, but GWT doesn't seem able to read it	
	/*session_start();
	$_SESSION['email']=$email;
	//session_id();
	$DURATION = 1209600000;//(1000 * 60 * 60 * 24 * 14);
	//Cookies.setCookie("bookWhacksid", sessionID, expires, null, "/", false);
	setcookie("bookWhacksid", session_id(), time()+$DURATION);*/
	//echo "Thank you, your account has been activated\nwww.bookwhack.co.uk";
	$redirectURL = "redirect.html";
	header("Location:$redirectURL");

// Delete information of this user from table "temp_members_db" that has this passkey
$sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'";
$result3=mysqli_query($link,$sql3);
}

}
?>