I need to check if $_POST
variables exist using single statement isset.
if (isset$_POST['name'] && isset$_POST['number'] && isset$_POST['address'] && etc ....)
is there any easy way to achieve this?
I need to check if $_POST
variables exist using single statement isset.
if (isset$_POST['name'] && isset$_POST['number'] && isset$_POST['address'] && etc ....)
is there any easy way to achieve this?
Or, Iterate through each
$_POST
key/pairThe last way is probably your easiest way - if any of your
$_POST
variables change you don't need to update an array with the new names.Do you need the condition to be met if any of them are set or all?
if isset(($_POST['name']) && ($_POST['number']) && ($_POST['address']))
You can also use this. it might be more easy.
The following is a custom function that take an array for the required posted elements as a parameter and return true if they all posted and there is no any of them is empty string
''
or false if there is at least one of them is not:Old post but always useful