Also, when testing your code, it's not displaying error message at all in case
I entered less than 3 characters and invalid email address format. So, please
try the following code and see if error message is displayed in the same case.
PHP Code:
<?php
define("EMAIL", "jock@jockitdesign.com");
if(isset($_POST['submit'])) {
include('validate.class.php');
//assign post data to variables
$firstname = trim($_POST['firstname']);
$surname = trim($_POST['surname']);
$email = trim($_POST['email']);
$contactnumber = trim($_POST['contactnumber']);
$propertyprice = trim($_POST['propertyprice']);
$propertylocation = trim($_POST['propertylocation']);
$message = trim($_POST['message']);
//start validating our form
$v = new validate();
$v->validateStr($firstname, "firstname", 3, 75);
$v->validateStr($surname, "surname", 3, 75);
$v->validateEmail($email, "email");
$v->validateStr($contactnumber, "contactnumber", 3, 75);
$v->validateStr($propertyprice, "propertyprice", 3, 75);
$v->validateStr($propertylocation, "propertylocation", 3, 75);
$v->validateStr($message, "message", 5, 500);
if(!$v->hasErrors()) {
$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "CutmoreProperty.com | Contact Enquiry";
$email_to = EMAIL;
$emailMessage = "First Name: " . $firstname . "\n";
$emailMessage .= "Surname: " . $surname . "\n\n";
$emailMessage .= "Email: " . $email . "\n";
$emailMessage .= "contactnumber: " . $contactnumber . "\n\n";
$emailMessage .= "propertyprice: " . $propertyprice . "\n";
$emailMessage .= "propertylocation: " . $propertylocation . "\n\n";
$emailMessage .= $message;
//use php's mail function to send the email
$sent = mail($email_to, $subject ,$emailMessage ,$header );
if($sent) echo
'<script language="javascript" type="text/javascript">
// Print a message
alert("Thank you for the message. We will contact you shortly.");
// Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
window.location = "../contact.php";
</script>';
} else {
//set the number of errors message
$message_text = $v->errorNumMessage();
echo $message_text;
//store the errors list in a variable
$errors = $v->displayErrors();
echo $errors;
//get the individual error messages
$firstnameErr = $v->getError("firstname");
$surnameErr = $v->getError("surname");
$emailErr = $v->getError("email");
$contactnumberErr = $v->getError("contactnumber");
$propertypriceErr = $v->getError("propertyprice");
$propertylocationErr = $v->getError("propertylocation");
$messageErr = $v->getError("message");
}//end error check
}
?>