I am not sure about the code that i have written below. A newbie here so i suspect there is something wrong with my coding. Can anyone tell me? I have this form that will need certain fields to be filled and i want to use array to check whether the required fields are filled or not. I will use function filled_out for the checking. But not sure how to write the array for the required fields. I include the code for the array and also the function. I will really appreciate your help. Thank you in advance.
Code: Select all
<?php
function filled_out($required)
{
// test that each variables has a value
foreach ($required as $key =>$value)
{ if (!isset($key) || ($value == ''))
return false;
}
return true;
}
$required = array( 1=>$Courses_Registered, $FirstName, $LastName, $Salutations, $Gender, $Citizenship, $DOB, $Street, $Building, $City, $Country, $Zip, $Educational_Level, $Title, $Primary_Responsibility, $Management_Level, $Company_Name, $Business_Tel, $Fax, $Email,
$Industry, $Employees_Number, $Annual_Sales, $Business_Street, $Business_Street, $Business_Building, $Business_City, $Business_Country, $Business_Zip, $How_Heard);
//check forms filled in
if (!filled_out($required))
{
header("Location:missing.html");
}
?>