Results 1 to 4 of 4

Thread: [RESOLVED] Checking if not postback

  1. #1

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Resolved [RESOLVED] Checking if not postback

    Me again.
    Follow up to my last resolved thread. This seems to be almost the same question that I escaped with a better tactic thanks to zalez in my last post, but I still don't know how to handle this instance.

    Say you have a POST method form that contains a couple of inputs and all must be set and not empty before continuing. If they are not set and empty then you print "Fill in all fields.", for example, to the page.

    The default values are empty and not set, so when you navigate to the page for the first time, you print your message immediately.

    How in PHP do I tell if the user actually tried to submit the inputs with a button click, in this case, and it is not just the first navigation to the page?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Checking if not postback

    if ($_SERVER['REQUEST_METHOD'] == 'POST')

  3. #3
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    326

    Re: Checking if not postback

    penagate's method is how you would tell if the page was posted. As for making sure the fields are filled in, you could use an if statement and look for empty fields. I know this could be cumbersome if you have alot of fields but it is the only way that I have done it with out using third party scripts.

  4. #4

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Checking if not postback

    Great! Thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width