I have created a form on my website but for some reason 3 sections of the form arenot submitting correctly. After clicking submit I recieve this on screen:
'We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
The RAID you entered do not appear to be valid.
The Accessories you entered do not appear to be valid.
The Guarantee you entered do not appear to be valid.
Please go back and fix these errors.'
This is the PHP for the form:
I was getting the error for every field entered but seems to just be the three now.
'We are very sorry, but there were error(s) found with the form you submitted. These errors appear below.
The RAID you entered do not appear to be valid.
The Accessories you entered do not appear to be valid.
The Guarantee you entered do not appear to be valid.
Please go back and fix these errors.'
This is the PHP for the form:
Code:
if(isset($_POST['email'])) {
$email_to = "matt.email@gmail.com";
$email_subject = "Custom Form";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['role']) ||
!isset($_POST['ram']) ||
!isset($_POST['raid']) ||
!isset($_POST['hdd1']) ||
!isset($_POST['hdd2']) ||
!isset($_POST['os']) ||
!isset($_POST['gpu']) ||
!isset($_POST['extras']) ||
!isset($_POST['accessories']) ||
!isset($_POST['guarantee']) ||
!isset($_POST['customer']) ||
!isset($_POST['budget'])) {
}
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_from = $_POST['email'];
$Role = $_POST['role'];
$Memory_Size = $_POST['ram'];
$RAID = $_POST['raid'];
$Hard_Drive_1 = $_POST['hdd1'];
$Hard_Drive_2 = $_POST['hdd2'];
$Operating_System = $_POST['os'];
$Graphics_Card = $_POST['gpu'];
$Optional_Extras = $_POST['extras'];
$Accessory_Packs = $_POST['accessories'];
$Guarantee = $_POST['guarantee'];
$Customer_Specifics = $_POST['customer'];
$Maximum_Budget = $_POST['budget'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($Role) < 2) {
$error_message .= 'The Role you entered do not appear to be valid.<br />';
}
if(strlen($Memory_Size) < 2) {
$error_message .= 'The RAM you entered do not appear to be valid.<br />';
}
if(strlen($RAID) < 2) {
$error_message .= 'The RAID you entered do not appear to be valid.<br />';
}
if(strlen($Hard_Drive_1) < 2) {
$error_message .= 'The HHD1 you entered do not appear to be valid.<br />';
}
if(strlen($Hard_Drive_2) < 2) {
$error_message .= 'The HDD2 you entered do not appear to be valid.<br />';
}
if(strlen($Operating_System) < 2) {
$error_message .= 'The OS you entered do not appear to be valid.<br />';
}
if(strlen($Graphics_Card) < 2) {
$error_message .= 'The GPU you entered do not appear to be valid.<br />';
}
if(strlen($Optional_Extras) < 2) {
$error_message .= 'The Extras you entered do not appear to be valid.<br />';
}
if(strlen($Accessory_Packs) < 2) {
$error_message .= 'The Accessories you entered do not appear to be valid.<br />';
}
if(strlen($Guarantee) < 2) {
$error_message .= 'The Guarantee you entered do not appear to be valid.<br />';
}
if(strlen($Customer_Specifics) < 2) {
$error_message .= 'The Customer Specifics you entered do not appear to be valid.<br />';
}
if(strlen($Maximum_Budget) < 2) {
$error_message .= 'The Maximum Budget you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Role: ".clean_string($Role)."\n";
$email_message .= "Memory Size: ".clean_string($Memory_Size)."\n";
$email_message .= "RAID: ".clean_string($RAID)."\n";
$email_message .= "Hard Drive 1: ".clean_string($Hard_Drive_1)."\n";
$email_message .= "Hard Drive 2: ".clean_string($Hard_Drive_2)."\n";
$email_message .= "Operating System: ".clean_string($Operating_System)."\n";
$email_message .= "Graphics Card: ".clean_string($Graphics_Card)."\n";
$email_message .= "Optional Extras: ".clean_string($Optional_Extras)."\n";
$email_message .= "Accessory Packs: ".clean_string($Accessory_Packs)."\n";
$email_message .= "Guarantee: ".clean_string($Guarantee)."\n";
$email_message .= "Customer Specifics: ".clean_string($Customer_Specifics)."\n";
$email_message .= "Maximum Budget: ".clean_string($Maximum_Budget)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
Thank you for requesting a quote.
<?php
}
die();
?>
<body>
</body>
</html>
Comment