Re: [PHP] Form data is not "remembered"
Hi, Actually, the reason why form data is not remembered is because I use sessions, and when you use sessions, the browser is told not to cache anything, which is pretty smart actually. The easy solution is to store the user's input into a session variable to "remember" it that way, and display the form again in case of an error with the saved values restored into the form. This is particularly easy if you have an object that you want to define using your form; you can easily save the whole object as a session variable. ""Alain Fontaine"" <[EMAIL PROTECTED]> a écrit dans le message news: 94m9ie$mru$[EMAIL PROTECTED] > Hi, > > I have a page with a couple of form fields that are being POSTed to a > processing PHP script. The page that contains these form fields is itself a > PHP page that uses sessions and so on. > > I have to make "server-side data validation" on the fields because of their > complexity. When the user hits submit and comes to the result page, if there > was any error I ask the user to go back to the form and correct the > mistakes, using either his browser BACK button or by clicking on a link that > does a javascript:history.back(). > > The problem is, when the user gets back to the form page, all of the values > he had typed in are gone, and he has to start all over again. Does anyone > have an idea why this is so, and how to circumvent it without saving the > user data into a session variable and then setting it back again once the > user hits the form page again ? I have seen many pages where your previous > data would stay in the form after you make a "Back" operation, but here, it > disappears. > > Thanks for any ideas, and have a very nice day. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form data is not "remembered"
> If the form page is not being cached, it would probably get reloaded > when they clicked back, thus losing the data. > > I'd suggest redrawing the form with the fields populated and with the > appropriate error messages. Then you don't need to mess with caches or > sessions for that matter, and the user doesn't need to take an extra > step to get back to the form. yep, best way is to move the control of your form into the php script itself, so the script can spit up the form with errors, saying "you screwed this, and that up" instead of making them go back, which 90% of the time will force them to re-enter the data, and we all know how much that sucks :) in short, don't use the php script like most people use cgi scripts. have it control the entire peocess. -alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form data is not "remembered"
If the form page is not being cached, it would probably get reloaded when they clicked back, thus losing the data. I'd suggest redrawing the form with the fields populated and with the appropriate error messages. Then you don't need to mess with caches or sessions for that matter, and the user doesn't need to take an extra step to get back to the form. Alain Fontaine wrote: > > Hi, > > I have a page with a couple of form fields that are being POSTed to a > processing PHP script. The page that contains these form fields is itself a > PHP page that uses sessions and so on. > > I have to make "server-side data validation" on the fields because of their > complexity. When the user hits submit and comes to the result page, if there > was any error I ask the user to go back to the form and correct the > mistakes, using either his browser BACK button or by clicking on a link that > does a javascript:history.back(). > > The problem is, when the user gets back to the form page, all of the values > he had typed in are gone, and he has to start all over again. Does anyone > have an idea why this is so, and how to circumvent it without saving the > user data into a session variable and then setting it back again once the > user hits the form page again ? I have seen many pages where your previous > data would stay in the form after you make a "Back" operation, but here, it > disappears. > > Thanks for any ideas, and have a very nice day. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Monte Ohrt <[EMAIL PROTECTED]> http://www.ispi.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form data is not "remembered"
At 2:41 AM -0800 1/24/01, Klepto wrote: >Try the "GET" method in the form. > >Jaks >- Original Message - >From: Alain Fontaine <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, January 24, 2001 2:11 AM >Subject: [PHP] Form data is not "remembered" > > >> Hi, >> >> I have a page with a couple of form fields that are being POSTed to a >> processing PHP script. The page that contains these form fields is itself >a >> PHP page that uses sessions and so on. >> >> I have to make "server-side data validation" on the fields because of >their >> complexity. When the user hits submit and comes to the result page, if >there >> was any error I ask the user to go back to the form and correct the >> mistakes, using either his browser BACK button or by clicking on a link >that >> does a javascript:history.back(). >> >> The problem is, when the user gets back to the form page, all of the >values >> he had typed in are gone, and he has to start all over again. Does anyone >> have an idea why this is so, and how to circumvent it without saving the >> user data into a session variable and then setting it back again once the >> user hits the form page again ? I have seen many pages where your previous >> data would stay in the form after you make a "Back" operation, but here, >it > > disappears. > > Some browsers will save the entered info when you hit the BACK button, some won't; it also depends on your HTTP header settings (no-cache, must-revalidate, etc.). Probably bad idea to rely on that. In a nutshell, if your validation fails, don't tell the user to hit the back button. Instead, redisplay the form with the data fields already filled in. I usually write my form display & process programs something like this (assuming $Submit is the name attribute of the submit button): ... if ($Submit = 'Enter your data') { $ErrorList = validate_form_data(); if (is_array($ErrorList)) { show_form($ErrorList); } else { process_data(); } } else { show_form(); } ... Where: validate_form_data is a function that returns an array of error messages like $ErrorList[] = , or FALSE if all tests passed. If there are errors, I redisplay the form with entered data (from $HTTP_POST_VARS or wherever), and error messages displayed alongside the appropriate form fields. show_form displays the entry form, with any existing data (from HTTP_POST_VARS, etc.) filled in and error messages, if any, displayed. Basically, the FORM tag action attribute refers to the same program as displayed the form - that is, $PHP_SELF. Hope this is clear...I getting tired, and I don't even think an intravenous drip of concentrated Mountain Dew syrup will help. - steve -- +--- "They've got a cherry pie there, that'll kill ya" --+ | Steve Edberg University of California, Davis | | [EMAIL PROTECTED] Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-- FBI Special Agent Dale Cooper ---+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form data is not "remembered"
Hi, Thanks for the hint, but using GET method doesn't change anything, unfortunately. "Klepto" <[EMAIL PROTECTED]> a écrit dans le message news: 001401c085f2$3c8801a0$[EMAIL PROTECTED] > Try the "GET" method in the form. > > Jaks > - Original Message - > From: Alain Fontaine <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, January 24, 2001 2:11 AM > Subject: [PHP] Form data is not "remembered" > > > > Hi, > > > > I have a page with a couple of form fields that are being POSTed to a > > processing PHP script. The page that contains these form fields is itself > a > > PHP page that uses sessions and so on. > > > > I have to make "server-side data validation" on the fields because of > their > > complexity. When the user hits submit and comes to the result page, if > there > > was any error I ask the user to go back to the form and correct the > > mistakes, using either his browser BACK button or by clicking on a link > that > > does a javascript:history.back(). > > > > The problem is, when the user gets back to the form page, all of the > values > > he had typed in are gone, and he has to start all over again. Does anyone > > have an idea why this is so, and how to circumvent it without saving the > > user data into a session variable and then setting it back again once the > > user hits the form page again ? I have seen many pages where your previous > > data would stay in the form after you make a "Back" operation, but here, > it > > disappears. > > > > Thanks for any ideas, and have a very nice day. > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Form data is not "remembered"
Try the "GET" method in the form. Jaks - Original Message - From: Alain Fontaine <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 24, 2001 2:11 AM Subject: [PHP] Form data is not "remembered" > Hi, > > I have a page with a couple of form fields that are being POSTed to a > processing PHP script. The page that contains these form fields is itself a > PHP page that uses sessions and so on. > > I have to make "server-side data validation" on the fields because of their > complexity. When the user hits submit and comes to the result page, if there > was any error I ask the user to go back to the form and correct the > mistakes, using either his browser BACK button or by clicking on a link that > does a javascript:history.back(). > > The problem is, when the user gets back to the form page, all of the values > he had typed in are gone, and he has to start all over again. Does anyone > have an idea why this is so, and how to circumvent it without saving the > user data into a session variable and then setting it back again once the > user hits the form page again ? I have seen many pages where your previous > data would stay in the form after you make a "Back" operation, but here, it > disappears. > > Thanks for any ideas, and have a very nice day. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Form data is not "remembered"
Hi, I have a page with a couple of form fields that are being POSTed to a processing PHP script. The page that contains these form fields is itself a PHP page that uses sessions and so on. I have to make "server-side data validation" on the fields because of their complexity. When the user hits submit and comes to the result page, if there was any error I ask the user to go back to the form and correct the mistakes, using either his browser BACK button or by clicking on a link that does a javascript:history.back(). The problem is, when the user gets back to the form page, all of the values he had typed in are gone, and he has to start all over again. Does anyone have an idea why this is so, and how to circumvent it without saving the user data into a session variable and then setting it back again once the user hits the form page again ? I have seen many pages where your previous data would stay in the form after you make a "Back" operation, but here, it disappears. Thanks for any ideas, and have a very nice day. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]