I’m trying to store the user’s email, using a session to use across multiple pages.
Scenario: A user registers with their credentials, and is stored in the customer table. The user email is the PK of the table and therefore is unique. On success, the user is redirected to a booking page where the user can go ahead and make a booking. The user email is needed to reference the customer when making the booking, for the booking table (being the FK). “is needed to carry forward to the booking page.” - from tasks.
[php]
<?php session_start();
?>
BookMe
// HTML form code
…
…
.
<?php
// user input validations - working fine
// connect to server
// pre check select statement to see if user email exists
// if fails, error message is displayed
// else (success),
else{
// insert statement into customer table
//$query = mysqli_query($DBConnect, "INSERT INTO customer(cust_name, cust_pass, cust_email, cust_phone) VALUES ('$userName', '$userPassword1', '$userEmail', '$userPhone')");
// if $userEmail matches then register a session and redirect to booking.php
//$userCheck = mysqli_query($DBConnect, "SELECT * FROM customer WHERE cust_email = '" . $userEmail . "'");
$_SESSION['userEmail'] = $userEmail;
echo "Registration Success, '
".$_SESSION['userEmail']."'.";
echo "Please wait while we redirect you to the Booking Page";
// if successful redirect to booking.php page
header('Location: booking.php');
}
// close database
mysqli_close($DBConnect);
[/php]
Where I currently have the session variable storing the user email, it's working. How do I get this to work across multiple pages, i.e the booking page. Is this being stored in the right place?