<?php
$name=$_POST['name'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$emailAddress=$_POST['emailAddress'];
//It's receiving the variables correctly, I've checked by printing the variables.
$errors=array(); //Creates empty array with 0 indexes. This will now be filled with error messages (if there are any errors).
if($name=="" || $subject=="" || $message=="" || $emailAddress=""){
if($name==""){
$errors[0]="You did not supply a name.";
}
if($subject==""){
$errors[count($errors)]="You did not supply a subject."; //I'm using count($errors) so it will create a new index at the end of the array, regardless of how many indexes it currently has (if that makes sense, it's hard to explain)
}
if($message==""){
$errors[count($errors)]="You did not supply a message.";
}
if($emailAddress==""){
$errors[count($errors)]="You did not supply an email address.";
}
}
//Were there any errors?
if(!count($errors)==0){
print "The following errors were found:<br />";
for($i=0; $i<count($errors); $i++){
print $errors[$i]."<br />";
}
die ();
}
//Rest of email script, which I'll write when the stupid bug is fixed. :(
?>