Help to Validate Form DEADLINE

I’ve done a search and I can’t seem to find what I’m looking for, I have a deadline so I need help ASAP. Just help with one field to validate, than I can figure out the rest.

Here’s the form: http://www.esl4work.com/form.html

Thanks in advance.

Here’s the PHP code:

[COLOR=DarkRed]<?php

if(isset($_POST[‘submit’])) {

$firstName = $_POST[‘txtFirstName’];
$lastName = $_POST[‘txtLastName’];
$company = $_POST[‘txtCompany’];
$email = $_POST[‘txtEmail’];
$phone = $_POST[‘txtPhone’];
$hearAbout = $_POST[‘selHearAbout’];
$quest1 = $_POST[‘txtQuest1’];
$quest2 = $_POST[‘txtQuest2’];
$quest3 = $_POST[‘selQuest3’];
$quest4 = $_POST[‘txtOther’];
$quest5 = $_POST[‘txtQuest5’];

foreach($_POST[‘check’] as $value) {
$check_msg .= "Checked: $value
";
}

$body = "From: $firstName $lastName
E-Mail: $email

  1. What are the current positions of the participants?
    $quest1

  2. Approximately how many participants would be interested in talking an ESL course?
    $quest2

  3. What English Proficiency would you place the majority of the participants?
    $quest3

  4. Which areas of English do the participants need improvement in?
    $check_msg
    Other:
    $quest4

  5. What are your organizations top three goals for running an on-site ESL program?
    $quest5
    ";

header (‘location: http://www.esl4work.com/thank-you.html’);
mail($to, $subject, $body);

}

else {

header (‘location: http://www.esl4work.com/error.html’);

}

?>[/COLOR]

Which field do you need to validate? Lets assume that it’s the first name… First, I would put the form itself into a function so that you can reuse it if the validation fails. Just pass the form function an array that represents the $_POST array. Then echo the appropriate array key in the form field value attribute like so:


echo "<input type=\"text\" name=\"txtFirstName\" value=\"$postValues['txtFirstName']\" />";

Then, after submission:


if(isset($_POST['submit'])) 
{
     //you could use regular expression matching for phone, email
     if($_POST['txtFirstName'] != '')
     {
          $firstName = $_POST['txtFirstName'];
          $lastName = $_POST['txtLastName'];
          //etc...
     }
     else
     {
         echo "<h2>ERROR MESSAGE</h2>";
         $form = formFunction($_POST);
     }
}
else
{
     echo "<h2>FILL OUT FORM</h2>";
     $form = formFunction();
}

But I still like to use Javascript validation because it validates before the form is submitted to the server, so it is a little bit quicker