Jump to content

empty $_POST array so reload doesn't duplicate


re5etsmyth

Recommended Posts

i do see that it seems to empty everything, judging by:

echo count($_POST);
unset($_POST);
echo count($_POST);

however, even with the above, if i reload i get a repost notice, and the first echo will have a count like it was posted to.  how do i fix that?

Unfortunately, this is a browser setting.
To get around it, maybe a header() could be used, or a conditional <meta refresh> tag if there's post data, but that's a little clunky.

It begs the question, though, why post to the same page? :D
Posting to the same page make redisplay of the form with the entered data easier if there are any validation errors. What you can do is if the validations succeed, jump to another page via the header() function (as long as you haven't sent any output to the browser). You then output any success message in the new script.

Ken
[quote author=keeB link=topic=117165.msg477779#msg477779 date=1165121629]
It begs the question, though, why post to the same page? :D
[/quote]

this is a plugin for wordpress, and keeping it down to 1 page is very desirable.

[quote author=kenrbnsn link=topic=117165.msg477783#msg477783 date=1165123155]
jump to another page via the header() function (as long as you haven't sent any output to the browser). You then output any success message in the new script.
[/quote]

unfortunately for me, header() requires an absolute path, and being that this is a plugin, i will never really know the path.  php.net shows how to find the path when the file you are header()ing back to is in the same directory, but not in a directory several directories below, which is needed for the plugin because it is being included elsewhere.

for the time being, i am posting to a different page, and using an onload to submit a form back to my original page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.