I realized that not only was i trying to make things more complicated for myself I was also working in an external sheet. So when I defined, action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
The form was looking on the page for the script. Therefore could not locate the variables. Additionally, some of you pointed out case sensitive errors, which I have also addressed. The complete script now works like a charm, so i thank you again for your help. :)
PHP Solution
<?php
//*--/ variables /--*//
$emailSubject = 'Email Title';
$webMaster = 'php.test@outlook.com';
//*--/ define variables and set to empty values /--*//
$first_nameErr = $last_nameErr = $email_fieldErr = $tel_fieldErr = $select_optionErr = $enquiry_areaErr = "";
$first_name = $last_name = $email_field = $tel_field = $select_option = $enquiry_area = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["firstname"])) {
$first_nameErr = "First name is a required field.";
} else {
$first_name = test_input($_POST["firstname"]);
}
if (empty($_POST["lastname"])) {
$last_nameErr = "Last name is a required field.";
} else {
$last_name = test_input($_POST["lastname"]);
}
if (empty($_POST["email"])) {
$email_fieldErr = "E-mail is a required field.";
} else {
$email_field = test_input($_POST["email"]);
}
if (empty($_POST["tel"])) {
$tel_fieldErr = "Tel No. is a required field.";
} else {
$tel_field = test_input($_POST["tel"]);
}
if (empty($_POST["select"])) {
$select_option= "";
} else {
$select_option = test_input($_POST["select"]);
}
if (empty($_POST["enquiry"])) {
$enquiry_areaErr = "Enquiry is a required field.";
} else {
$enquiry_area = test_input($_POST["enquiry"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$body = <<<EOD
<br><hr><br>
First Name: $first_name <br>
Last Name: $last_name <br>
Email: $email_field <br>
Tel: $tel_field <br>
I heard about you from; $select_option <br>
Enquiry: $enquiry_area <br>
EOD;
$headers = "From: $email_field
";
$headers .= "Content-type: text/html
";
$success = mail($webMaster,$emailSubject, $body, $headers);
?>
HTML Solution " method="POST">
<!--/ form left /-->
<div id="form-left">
<input type="text" name="first_name" placeholder="First Name" maxlength="64"><span class="error">* <?php echo $first_nameErr; ?></span><br>
<input type="text" name="last_name" placeholder="Last Name" maxlength="64"><span class="error">* <?php echo $last_nameErr; ?></span><br>
<input type="text" name="email" placeholder="JohnDoe@example.com" maxlength="128"><span class="error">* <?php echo $email_fieldErr; ?></span><br>
<input type="text" name="tel" placeholder="Tel No." maxlength="16"><span class="error">* <?php echo $tel_fieldErr; ?></span><br>
<input type="reset">
</div>
<!--/ form right /-->
<div id="form-right">
<select>
<option value="where" name="select" selected>How did you find us? ▼</option>
<option value="facebook">Facbook</option>
<option value="twitter">Twitter</option>
<option value="event">An Event</option>
<option value="friend">A Friend</option>
<option value="partner">A Partner</option>
<option value="other">Other</option>
</select> <br>
<textarea name="enquiry" placeholder="Have an enquiry?" maxlength="750"></textarea><span class="error">* <?php echo $enquiry_areaErr; ?></span>
</div>
<div id="form-submit">
<input type="submit" onClick="alert('Thank you, your enquiry has been recieved.')">
</div>
</div>
</form>