Page 1 of 1

how to handle missing $_POST parameters

Posted: Wed Mar 31, 2004 8:32 am
by davidklonski
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

Posted: Wed Mar 31, 2004 8:33 am
by patrikG
use

Code: Select all

header("cache: private");
at the top of the page.

Posted: Wed Mar 31, 2004 9:34 am
by Steveo31
Just curious, is there any difference in using the same name as the page, as opposed to $_SERVER['PHP_SELF']; ?

Posted: Wed Mar 31, 2004 9:39 am
by patrikG
$_SERVER['PHP_SELF'] returns the name of the "page" that either calls or contains the php-script.