spangle1187 Posted June 24, 2011 Share Posted June 24, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/ Share on other sites More sharing options...
fugix Posted June 24, 2011 Share Posted June 24, 2011 In your process_booking_success.php page, do you have session_start() at the very top of your code? Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234343 Share on other sites More sharing options...
micah1701 Posted June 24, 2011 Share Posted June 24, 2011 are you calling session_start() on the "process booking page" you have to add session_start(); at the top of every page that uses sessions. Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234344 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 Every page has a session start() Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234348 Share on other sites More sharing options...
fugix Posted June 24, 2011 Share Posted June 24, 2011 If you are sure that you have session_start() on your process_booking_success.php page, on that same page, what does print_r($_SESSION); output? Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234349 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 It prints out nothing Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234351 Share on other sites More sharing options...
micah1701 Posted June 24, 2011 Share Posted June 24, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234353 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 Sorry it did print out some data Array ( [username] => admin => [email protected] [ourdate] => 06/24/2011 [booking] => ) Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234355 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 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'];?> Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234356 Share on other sites More sharing options...
fugix Posted June 24, 2011 Share Posted June 24, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234365 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 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] => [email protected] [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; Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234370 Share on other sites More sharing options...
fugix Posted June 24, 2011 Share Posted June 24, 2011 Since $data is a string, there should be no problems assigning it to the session. Try setting $data to a string like "test string" Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234374 Share on other sites More sharing options...
spangle1187 Posted June 24, 2011 Author Share Posted June 24, 2011 Still comes back the same on the print_r Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234384 Share on other sites More sharing options...
fugix Posted June 24, 2011 Share Posted June 24, 2011 I'll have to see more if your code on both pages before I can help further Quote Link to comment https://forums.phpfreaks.com/topic/240308-_session-data-help-please/#findComment-1234385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.