www.webdeveloper.com
Results 1 to 5 of 5

Thread: Working out the send method GET/POST

  1. #1
    Join Date
    May 2003
    Posts
    55

    Post Working out the send method GET/POST

    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
    }

  2. #2
    Join Date
    May 2003
    Location
    France
    Posts
    7
    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

  3. #3
    Join Date
    May 2003
    Posts
    55
    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...

  4. #4
    Join Date
    May 2003
    Posts
    55
    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

  5. #5
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    You should be able to use this:
    PHP Code:
    if (getenv("REQUEST_METHOD") == "POST"){
      
    // Request method is POST.
    } else {
      
    // Request method is (probably) GET.

    Adam

    P.S. See the getenv() manual page.
    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles