I have looked everywhere and searched high and low. I have seen many issues with the PHP code I'm about to post, but nothing pertaining to my specific issue I am seeing.
Here is my issue - The two lines ($values/$required) where I have 'name','email',subject','message'
I would like to add 'tel' to it. (i.e. 'name','email','tel','subject','message')
If I add it to one of the two lines (doesn't matter which one), I can still submit the form but it doesn't give me that line (telephone) in the email I receive.
If I add the 'tel' to BOTH lines ($values/$required) then I get a "Please fill in all required fields, marked with *" when I hit submit (with all the lines filled out).
Can someone tell me what I am missing?
Also - 'subject' is actually a vin/body # but if I change the label in the html to 'vin' instead of 'subject' then it gives me the "Please fill in all required fields, marked with *" error so I just left it as 'subject' even though that is not what is really associated with that line item in the form.
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) {
echo $error;
} else {
$values = array('name','email','subject','message',);
$required = array('name','email','subject','message',);
$your_email = "[email protected]";
$email_subject = "VIN / Body - ".$_POST['subject'];
$email_content = "PART INQUIRY INFORMATION BELOW \n";
foreach ($values as $key => $value) {
if (in_array($value,$required)) {
if ($key != 'subject' && $key != 'company') {
if (empty($_POST[$value])) {
echo 'Please fill in all required fields, marked with *';
exit;
}
}
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>