RE: Go Back Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:cyrus_chan@xxxxxxxxxxxxxxxx] 
> Sent: Wednesday, December 01, 2004 5:59 PM
> To: php-general@xxxxxxxxxxxxx
> Subject:  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 
> works....pls help me.
> 
> Thanks and Regards,
> 
> Cyrus Chan
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux