I am working on a page where the user enters some information and the information is uploaded to a database. I am trying to figure out a way to loop through each form field and check for missing or incompatible information. As of now, I have been working with a foreach() loop that goes through and checks each form submission to make sure there is data there.
What I want to do is to display the title of the form field (ie "First Name" for first name and so on) next to the user's inputted data for that field. I am using an array to store all of the posted data from the forms as well as an array for all of the different form names. Here is the code:
foreach ($displayfieldarray as $line)
{
echo '<p class="sblacktext">'.$line.'</p>';
}
foreach ($inputarray as $component)
{
if(!$component)
{
echo '<p class="stext"><font color="red"><b>Nothing was entered.</b>';
exit;
} else {
echo $component;
}
}
Where $displayfieldarray = names of the form fields and $inputarray = user supplied information. I want to loop through both of these array's lining up each field name with the data the user described. How can this be done?