hi all, I have a a booking form which works just like a contact form but I am getting a error when I send the message
Here is the error
Notice: Undefined variable: errors in E:\domains\m\mossfarmcattery.co.uk\user\htdocs\contact.php on line 14
ERROR!
below is the form
<form action="contact.php" method="post" id="contactform">
<ol>
<li>
<label for="name"> Name <span class="red">*</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="contact"> Contact No. <span class="red">*</span></label>
<input id="contact" name="contact" class="text" />
</li><br />
<li>
<label for="company">Number of Cats</label>
<input type="radio" name="group1" value="1" checked> 1
<input type="radio" name="group1" value="2"> 2
<input type="radio" name="group1" value="3"> 3
<input type="radio" name="group1" value="4"> 4
</li><br />
<li>
<label for="subject">Date</label>Day
<script>
document.write("<select>");
for(i=0;i<31;i++){
var dateVar = 01 + i;
document.write('<option value=\"' + dateVar + '\">' + dateVar + '</option>');
}
document.write("</select>");
</script> Month
<script>
document.write("<select>");
for(i=0;i<12;i++){
var dateVar = 01 + i;
document.write('<option value=\"' + dateVar + '\">' + dateVar + '</option>');
}
document.write("</select>");
</script> Year
<script>
document.write("<select>");
for(i=0;i<2020;i++){
var dateVar = 2009 + i;
document.write('<option value=\"' + dateVar + '\">' + dateVar + '</option>');
}
document.write("</select>");
</script>
</li><br />
<li>
<label for="message">Message <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/send.gif" />
</li>
</ol>
</form>
and here is the php script
<?php
if(!$_POST) exit;
$email = $_POST['email'];
if (!preg_match('/[a-z0-9!#$%&\'*+\/=?\^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?\^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/', $email)) {
$error.="Invalid email address entered";
$errors=1;
} else {
// email is ok!
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "mail@steve-berrill.com";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>
help would be very excellent!🙂