How do I check to see if a value was posted from a form in PHP?

Posted on 2008-11-12
Last Modified: 2013-12-13
I'm new to PHP. I have a form with two drop down boxes. I need to check if the user has submitted the form by selecting one or both of the values so i can then use those values to query a database.

In ASP I would just check to see if the length of the request was greater than zero.
How do I do this in PHP?
Question by:Donnie Walker
    1 Comment
    LVL 82

    Accepted Solution

    assuming your dropdown has name="state", you would use:
    if( isset($_POST['state']) && !empty($_POST['state']) )

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now