Forum Moderators: coopster
function filled_out_pass($form_vars)
{
// test that each variable has a value
foreach ($form_vars as $key => $value)
{
if (!isset($key) ¦¦ ($value == ''))
return false;
}
return true;
}
$checkvals = filled_out_pass($_POST);
What you need to do is pass it only the values that you want to check. You can make a seperate array from the $_POST array and pass that to the function to check.
$HTTP_POST_VARS is the pre php 4.1.0 version of $_POST
At the moment you are passing all of the data posted from the form to your empty check function. It returns either true or false and processing continues based on the return value.
What you need to do is only pass the fields you want to check OR make the adjustment in the function. Since the function is so simple you could probably just put it straight in your code.
There are a bunch of ways to do it but I will give you an example. I will use an example with out the function.
$filled_out_pass = true;
// add the names of fields NOT to check
$nocheck = array('fax','cellnum','howhear');
foreach ($HTTP_POST_VARS as $key => $value) {
if (!in_array [ca.php.net]($key,$nocheck) && (!isset($key) ¦¦ ($value == '')))
$filled_out_pass = false;
}
if ($filled_out_pass) {
//continue processing
}
didn't test it but should work unless I messed up my AND(&&) OR(¦¦) logic, which happens. All I added essentially is that it now checks the var against an array of field names you don't want checked.