Check POST values in PHP

In some case you have to check what method was used to request your web page or check some values in POST parameters.

You have two options to check it using PHP.

1. Check if there’s ANY POST data at all

//Note: This resolves as true even if all $_POST values are empty strings
if (!empty($_POST))
{
    // handle post data
    $fromPerson = '+from%3A'.$_POST['fromPerson'];
    echo $fromPerson;
}

2. Only check if a PARTICULAR Key is available in post data

Try these PHP code to check some POST parameter:

if (isset($_POST['fromPerson']) )
{
    $fromPerson = '+from%3A'.$_POST['fromPerson'];
    echo $fromPerson;
}

Leave a Reply

Your email address will not be published. Required fields are marked *