Jump to content

$_SESSION data help please


spangle1187

Recommended Posts

In my project once I have processed a booking I am trying to get a summary of the booking to display on the successful booking page, so far I have added an extra $_SESSION data to the page that processes the users login:

 

    session_start();
$_SESSION['username'] = $username;
$_SESSION['email'] = mysql_result($result, 0);
$_SESSION['ourdate'] = date('m/d/Y');
$_SESSION['booking'];

The bottom line is for the booking summary.

 

On the process booking page I have added:

 

$data = "You have successfully made a booking for '$name' in room '$room' on the '$newDate' for the following times '$start_Time' to '$end_Time'";

It is here that I try to assign the above to the $_SESSION:

 

$_SESSION['booking'] = $data;

 

And then the site is directed to the booking success page:

 

header("Location: http://webdev/schools/hhs/psy_bookings/process_booking_success.php"); //booking success page

 

But when I get to the booking success page nothing is displayed, this is the code that I have used to display the booing summary:

 

<div id="wholepage">
<?php echo $_SESSION['booking'];?>
</div>

 

Can you please help?, the data is not in a form so that is why I have not used the $_POST option

Link to comment
Share on other sites

in your first block of code you posted that you have "$_SESSION['booking'];" 

 

is that at the top of any pages AFTER you give it a value of $data?  if so, the above code would overwrite any value you previously assigned to that session variable.

 

als, it's not neccessary to declare the session variables so you can take this line out anyway.

Link to comment
Share on other sites

in your first block of code you posted that you have "$_SESSION['booking'];" 

 

is that at the top of any pages AFTER you give it a value of $data?  if so, the above code would overwrite any value you previously assigned to that session variable.

 

als, it's not neccessary to declare the session variables so you can take this line out anyway.

 

No I give it the value then try to call it on the next page with:

 

<?php echo $_SESSION['booking'];?>

Link to comment
Share on other sites

Okay so the output that you showed me indicates that your variables are passing to that other page, but your booking session is empty. I would remove the empty declaration of your booking session. The only time you will need to declare the booking session is when you are setting it to the variable $data. Once you do that, perform a print_r($_SESSION)

Link to comment
Share on other sites

I have removed the blank deceleration from the process login page but the print_r is still printing the same data:

 

Array ( [username] => admin [email] => s.campbell@hud.ac.uk [ourdate] => 06/24/2011 [booking] => ) 

 

I guess the problem then lies with when I am trying to assign the $data variable to it so maybe on these two lines:

 

$data = "You have successfuly made a booking for '$name' in room '$room' on the '$newDate' for the following times '$start_Time' to '$end_Time'";

or

$_SESSION['booking'] = $data;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.