Page 1 of 1

php_self posting problem

Posted: Thu Jan 16, 2014 5:04 pm
by Gavski1
I have a form that contains a function. i want this function to be activated only when the user reposts the page to itself. (php_self).

ie. the user access the page and the function is hidden, the user then inputs data, repost the page and the function is activated.

I've tried flagging the function with a variable - $var = 0, then $var = 1 at the end of the page but $var just resets itself to 0 when the page is posted.

Sure this is simple but I just cant get it?


thanks

Re: php_self posting problem

Posted: Thu Jan 16, 2014 5:30 pm
by Celauran

Code: Select all

if (!empty($_POST)) {
    // do stuff after form has been submitted
}

Re: php_self posting problem

Posted: Thu Jan 16, 2014 5:39 pm
by requinix
Also mentioned recently, somewhere, is looking at the REQUEST_METHOD.

Code: Select all

if ($_SERVER["REQUEST_METHOD"] == "POST") {

Re: php_self posting problem

Posted: Fri Jan 17, 2014 5:35 am
by Gavski1
YES!, thanks guys,
both of these work fine, I love a simple solution! :D