{$item['Text']}\n"; } function VerifyForm(&$values, &$errors) { // Do all necessary form verification if ($values['contact'] != 'sales' && $values['contact'] != 'support') $errors['contact'] = 'Select department to contact'; if (strlen($values['name']) < 3) $errors['name'] = 'Name too short'; elseif (strlen($values['name']) > 50) $errors['name'] = 'Name too long'; // Needs better checking ;) if (!ereg('.*@.*\..{2,4}', $values['email'])) $errors['email'] = 'Email address invalid'; if (strlen($values['text']) == 0) $errors['text'] = 'Text required'; return (count($errors) == 0); } function DisplayForm($values, $errors) { $optionList = array( array('Value' => '', 'Text' => '(select one)'), array('Value' => 'sales', 'Text' => 'Sales'), array('Value' => 'support', 'Text' => 'Support'), ); ?> Yadda yadda 0) echo "

There were some errors in your submitted form, please correct them and try again.

"; ?>
Contact:
Name:
Email:
Text:
"); // Replace with actual page or redirect :P echo "Thank you!Thank you!"; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $formValues = $_POST; $formErrors = array(); if (!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else ProcessForm($formValues); } else DisplayForm(null, null); ?>