I create PHP session for storing the user email in 'submit.php' where before redirecting to paypal I register that user information into a database using MySQL. This is the code for creating the session in 'submit.php':
session_start();
$_SESSION['user-email']=$email;
So now the user pays at PayPal successfully and goes to 'thankyou.php' and I want to update my database saying the user paid and calling the PHP session:
session_start();
$email = $_SESSION['user-email'];
$con = mysql_connect("host.host.com","root","password");
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("somedatabase", $con);
$sql="UPDATE myTable SET status=1 WHERE email='$email'";
if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }
mysql_close($con);
Is the $_SESSION['user-email']; still alive at this point? Do I have any error? Why do you think my code is not working properly?
Thanks in advance