Re: How to skip browser's Warning?

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

 



On 9/13/06, afan@xxxxxxxx <afan@xxxxxxxx> wrote:

sorry, but didn't get this one. could you please elaborate it a little bi
to me?

thanks.



> On 9/13/06, afan@xxxxxxxx <afan@xxxxxxxx> wrote:
>>
>> Hi,
>> Could somebody explain to me what to do to skip this message I'm
getting
>> after I search for some products on my page, got the list of products,
>> selected a detailed view of the product and click on the Back button of
>> the browser to see again list of found products (result page):
>> "The Page you are trying to view contains POSTDATA that has expired
from
>> cache. If you resend the data, any action the form carried out such as
a
>> search or online purchase) will be repeated. To resend the data, click
>> OK.
>> Otherwise, click Cancel."
>>
>> Thanks for any help.
>>
>> -afan
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> If you add a header redirect [header('Location:');] after your script
> processes the POST data you can avoid this.
>

Sure..

Say you have form.php.  This page will post to process.php. (Just an
example.  Having form.php post to itself is fine too and how I always do my
forms since on error I redisplay them with filled values)

Inside process.php you might have something like

<?php
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
   //do processing here
   if ( success ) {
       header('Location: http://example.com/thanks.php');
   } else {
       header('Location: http://example.com/form.php');
   } // if
} // if

session_write_close(); // if you're using sessions
exit();
?>

Now when your form posts to process, your script will either go back to the
form.php on error, or thanks.php on success.  Because process.php issues a
redirect, this tells the browser to ignore process.php in the history it
saves.  If a user clicks the back button it will go to form.php because
process.php returned a 403 header and was "ignored" for lack of a better
word.

Hope that helps!

[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