Re: [PHP] Go Back Problem
I solve that problem this way (please correct me if it's wrong) # form.php if(isset($_POST['SubmitForm'])) { if(!isset($_POST['Name'] or !isset($_POST['Phone'] or !isset($_POST['Email']) { echo "One or more required fields are empty."; } else { header('location: results.php'); exit; } } ?> Name: Phone: Email: This way you don't need to go back if somethign's wrong and you go on result page ONLY if everything's correct. -afan Thomas Goyne wrote: On Thu, 2 Dec 2004 09:58:46 +0800, Cyrus <[EMAIL PROTECTED]> wrote: Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. Thanks and Regards, Cyrus Chan This is a browser issue. For some reason, most browsers interpet 'back' as 'reload the previous page' rather than 'go back to where the user was', which results in the information filled into forms being nuked. One possible workaround for this is to skip the back stage, thereby removing the chance for the data to be lost. On the preview page, just include the form, so that they can just make the changes there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Go Back Problem
On Thu, 2 Dec 2004 09:58:46 +0800, Cyrus <[EMAIL PROTECTED]> wrote: Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. Thanks and Regards, Cyrus Chan This is a browser issue. For some reason, most browsers interpet 'back' as 'reload the previous page' rather than 'go back to where the user was', which results in the information filled into forms being nuked. One possible workaround for this is to skip the back stage, thereby removing the chance for the data to be lost. On the preview page, just include the form, so that they can just make the changes there. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ http://www.smempire.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Go Back Problem
If your php form is entered via a post, my experience is that most browsers do not save post information, therefore, clicking "back" to a page that was entered via a form using the post method, the browser complains that it does not have enough information to display the form, and that you must retry or something like that. I have found that the simplest way to avoid this is divide each page into two php routines. Displaypage.php will check in session data for contents for the form, or fetch the information from the database, then it will format the html for the page with values from session variables or from the database. The action field of this form will specify the postform.php routine below. Postform.php will perform all validations and echo nothing to the browser. It will then either update session data or post the valid data to the database. The only output of this routine is a header sending the browser back to the previous module displaypage.php when it has done all it can. Notice that anytime you use a header to redirect the browser you can send variables if you need to via the URL parameter list "?var1=1&var2=2" string (they show up in the $_GET array). These variables are saved by all browsers that I know about, which means your displaypage.php program is never entered via a post (and always via a "get"), and because the redirect comes from the postform.php page, the postform.php module is removed from the browser history list by the redirect. This means that every click of the back button, or JavaScript history reference (-1) will take you back to the previous entry in the history list and if you are consistent, none of them will have been entered via a form post (i.e. no complaints). Hope this was clearer than mud, good luck. Warren Vail > -Original Message- > From: Cyrus [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 01, 2004 5:59 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Go Back Problem > > > Dear All, > > I have a problem of back to the previous page in php. > I need to create a form let people to fill in .It can let > user to preview the form, if information is not correct , > user can back to previous page and correct it, > I have used the javascript : OnClick='history.go(-1)' and > OnClick='history.back()' in php , but it can not > workspls help me. > > Thanks and Regards, > > Cyrus Chan > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Go Back Problem
On Thu, 2 Dec 2004 09:58:46 +0800, Cyrus <[EMAIL PROTECTED]> wrote: > Dear All, > > I have a problem of back to the previous page in php. > I need to create a form let people to fill in .It can let user to preview the > form, if information is not correct , user can back to previous page and > correct it, > I have used the javascript : OnClick='history.go(-1)' and > OnClick='history.back()' in php , but it can not workspls help me. The only way I've ever found was to change the form method to GET instead of POST, but that's not always desirable. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Go Back Problem
On Nov 26, 2004, at 7:59 PM, Cyrus wrote: Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. Thanks and Regards, Cyrus Chan What I do is store all the fields in $_SESSION variables, so when you go back to the page, if they filled that particular field out, it should show what they have already completed. -- if ($_POST["submitted"] == 1) { $_SESSION["field1"] = $_POST["something"]; $_SESSION["field2"] = $_POST["pizza"]; } ?> "/> "/> -- So, there's no need to use javascript or to actually "go back." You can just "redirect" to that page and have it "remember" the variables. To redirect back to it, use header("location: http://mysite.com/wherever.php";); It is not *always* necessary to use the absolute path to indicate that particular page in the header() function, but it doesn't hurt. Sorry if I have rambled on or confused you - it's late and I'm sleepy. Good luck with that. ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Go Back Problem
В сообщении от Суббота 27 Ноябрь 2004 04:59 Cyrus написал(a): > Dear All, > > I have a problem of back to the previous page in php. > I need to create a form let people to fill in .It can let user to preview > the form, if information is not correct , user can back to previous page > and correct it, I have used the javascript : OnClick='history.go(-1)' > and OnClick='history.back()' in php , but it can not workspls help > me. > > Thanks and Regards, > > Cyrus Chan you must store return point samewhere. f.e. in hidden area in your form, or in $_SESSION array -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php