Click to See Complete Forum and Search --> : Working out the send method GET/POST


nuthead
05-29-2003, 08:04 AM
I'm wanting to find out how a form was submitted either by GET or POST, in perl you use:
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
code
}

would this work instead or is there another way to do it?
if ($_ENV["REQUEST_METHOD"] == "POST") {
code
}

eraguet
05-29-2003, 09:15 AM
hi,
i don t know if it can help you,
but if you know one of the name of the field of the checked form, you can try to test if it is in the _POST array or the _GET array

example:
<input ... name='inpName' .... >

then you can test

if( isset($_POST[inpName]) ) .....

if( isset($_GET[inpName]) ) .....

hope this will help you.

ed

nuthead
05-29-2003, 11:08 AM
Originally posted by eraguet
hi,
i don t know if it can help you,
but if you know one of the name of the field of the checked form, you can try to test if it is in the _POST array or the _GET array

example:
<input ... name='inpName' .... >

then you can test

if( isset($_POST[inpName]) ) .....

if( isset($_GET[inpName]) ) .....

hope this will help you.

ed

would

if( isset($_POST) )

work? I'll try it and let you know...

nuthead
05-29-2003, 11:20 AM
Originally posted by nuthead
would

if( isset($_POST) )

work? I'll try it and let you know...

Ok, no it doesn't work, nor does if(_$POST != ""). The posted info could be a selection of things so I need to check if anything at all has been posted :(

AdamGundry
05-29-2003, 11:52 AM
You should be able to use this:
if (getenv("REQUEST_METHOD") == "POST"){
// Request method is POST.
} else {
// Request method is (probably) GET.
}

Adam

P.S. See the getenv() manual page (http://www.php.net/manual/en/function.getenv.php).