mike2325 Posted April 13, 2010 Share Posted April 13, 2010 Hi, Currently I have a website which includes 5 different pages. One of these is where a booking takes place. The user selects a time from a table, clicks book (a submit button) and the id is passed through to a different page where the id can be used to show the details of the booking. This all works even after viewing different pages, however if the page where the booking was originally made is visited again, the session is wiped and the other page showing the details of the booking shows no details. The booking page, as mentioned before is made up of a table where the user can select a booking time via a radio button. When this is clicked, the id of the time slot is entered into a hidden textbox. When the submit button is clicked the value of the textbox is passed to the other page using the session and is then reset. This must be the problem I am guessing but I do not know if there is a better way to make the textbox not reset? Any suggestions would be fantastic. Thanks. Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/ Share on other sites More sharing options...
aeroswat Posted April 13, 2010 Share Posted April 13, 2010 Hi, Currently I have a website which includes 5 different pages. One of these is where a booking takes place. The user selects a time from a table, clicks book (a submit button) and the id is passed through to a different page where the id can be used to show the details of the booking. This all works even after viewing different pages, however if the page where the booking was originally made is visited again, the session is wiped and the other page showing the details of the booking shows no details. The booking page, as mentioned before is made up of a table where the user can select a booking time via a radio button. When this is clicked, the id of the time slot is entered into a hidden textbox. When the submit button is clicked the value of the textbox is passed to the other page using the session and is then reset. This must be the problem I am guessing but I do not know if there is a better way to make the textbox not reset? Any suggestions would be fantastic. Thanks. My guess is your booking page has no checks against blank entries and it is re-submitting the information as a blank form. Just a guess tho. Need some code Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/#findComment-1041041 Share on other sites More sharing options...
mike2325 Posted April 13, 2010 Author Share Posted April 13, 2010 There are no checks against blank entries at the moment. I do not think that the page is being resubmitted, its as if this just happens without a resubmission. What is the best way to go about checking against blank entries? Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/#findComment-1041056 Share on other sites More sharing options...
aeroswat Posted April 13, 2010 Share Posted April 13, 2010 There are no checks against blank entries at the moment. I do not think that the page is being resubmitted, its as if this just happens without a resubmission. What is the best way to go about checking against blank entries? You need to do error checking on your form when its submitted. There are many different ways to do it. The way I do it is store my errors in an array and then print out a list of them at the top of the form page with all previous entries still in tact. You can also do it with javascript to check against it so that it doesn't even submit unless everything is correct. It sounds like it is re-submitting a blank form though if you don't have error checking. Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/#findComment-1041058 Share on other sites More sharing options...
mike2325 Posted April 13, 2010 Author Share Posted April 13, 2010 Reading on different websites it seems that I need to stop the data in my form resetting when the page is submitted. Is this possible? Thanks. Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/#findComment-1041064 Share on other sites More sharing options...
aeroswat Posted April 13, 2010 Share Posted April 13, 2010 Reading on different websites it seems that I need to stop the data in my form resetting when the page is submitted. Is this possible? Thanks. Yes of course. The easiest way is to have the form submit itself to the same page. That way you can re-use all of your php variables. So lets say you submit a form with the following form controls: Make Model Color and it is a POST submission. Your variables are now the following $_POST['Make'] $_POST['Model'] $_POST['Color'] And you can now use them to set the default value of your form controls like this <input type="text" name="Make" id="Make" value="<?php echo $_POST['Make']; ?>" /> etc... Link to comment https://forums.phpfreaks.com/topic/198397-some-trouble-with-sessions-resetting/#findComment-1041078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.