/    Sign up×
Community /Pin to ProfileBookmark

how to handle missing $_POST parameters

Hello

I have a page called ‘test.php’

The page contains a form with method POST
here is the definition:
<form method=”post” action=”test.php”>

As you see, the user submits the form to the same page the form was defined at.

Now, whenever I surf to that page directly, I get the following error message in the browser:

“The page cannot be refreshed without resending the information. Click Retry to send the information again, or click Cancel to return to the page that you were trying to view.”

If I click Retry then everything is ok.

How can I detect in PHP that no information has been sent?

thanks in advance

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@solavarMar 31.2004 — Are you saying that when you type the URL in the browser's address bar, the message appears?

In my experience, the only time that message appears is when I've hit 'Submit' and then tried to refresh the page which has already been submitted.
Copy linkTweet thisAlerts:
@davidklonskiauthorMar 31.2004 — Whe I type the URL in the address bar I get the following page:

Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.

To resubmit your information and view this Web page, click the Refresh button.
Copy linkTweet thisAlerts:
@shimonMar 31.2004 — I guess IE must be sort of caching the posted version of the page...strange

errrr it's kind of weird behaviour though

you could always try
[code=php]<form action="test.php/<?=time(); ?>">[/code]
then that way the post address gets timestamped, and the browser will think it's a seperate script

it might work..i dunno
×

Success!

Help @davidklonski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...