Reply to Re: [newbie] How to avoid FFox's "The page you are trying to view..."?

Your name:

Reply:


Posted by no on 12/10/06 16:42

On Sun, 10 Dec 2006 17:23:16 +0100, Vincent Delporte
<justask@acme.com> wrote:

>On Sun, 10 Dec 2006 10:38:59 -0500, bill <nobody@spamcop.net> wrote:
>>I presume you are reloading the page in a testing environment.
>>Right ?If so, there is no way to avoid the message. FF is just telling
>>you that you are about to resent the post data.
>
>Yup, but I would expect this if the page only contained a form and I
>hit F5 to reload. In the code I gave, the form is not even shown the
>second time around. So it seems like FireFox takes the safest route,
>and displays this message whenever a form (POST only?) is shown?
>
>Does it mean that it's not possible to use the same page to show a
>form and handle it with POST, ie. I must use action= to lead the user
>to another page?

I think you are misunderstanding the sequence of events. Sure, you can
recall the same page and have the script detect this and handle the
$_POST[] data - like this:

if ( $_SERVER['REQUEST_METHOD'=='POST' ) {

// handle the $_POST data here

} else {

// display the form HTML here

}

The first time into the script you will see the form (the second
block) ... hit refresh here and all you get is a blanked version of
the form each time - no messages.

Submit the form and in your action recall the page and now you're into
the first block of code that handles your $_POST[] data. If you
refresh this then you will get the message warning you that you are
going to resend the POST data again.

If you are really doing a post-type transaction with the data then
that post message is going to help you and stop you submitting another
copy of the form. But if you're just using the post data to read a
table or something where you are getting or displaying data then use
the GET method instead and you won't have any problems.

Alternatively, you can avoid the post message by doing your processing
(with no HTML output) and then use the header() function to redirect
the page somewhere else. This doesn't just redirect like the <meta>
redirect - it replaces the current page with the one you request - so
a refresh or back-page doesn't drop through the posting part of yoru
script again.

Chris R.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация