How to loop through $_POST
variables sent by a form to make sure none of them are empty or NULL. For example, if a form has 15 fields and is submitted. How to check that each of those 15 fields actually contained something other than NULL. I have multiple Forms but one validator class so I cannot specify the variable in the post array that need to be checked for each form.
I tried using foreach but that seemed to clear the $_POST
array or corrupt it for some reason? The not working code is given below. If I var_dump($_POST)
before I use the foreach and after the foreach I get an empty array after, but the correct values before. So I thing foreach is out of the question. Any Ideas?
foreach($_POST as $key => $value)
{
if ($value==NULL)
header ("Location: index.php")
}