Hi there, I hope someone can help.
I am working from a template that I bought from DreamTemplate and have been having lots of problems with the contact form. I contacted them but I may as well have been asking the fly that’s buzzing around my head to fix it!
The first problem is that I get “Invalid Email Address Entered” when I test it and can’t go any further. I did manage to resolve this but then encountered other problems. The only information that it collects is the name and message and the post submission message doesn’t appear correctly. Below is the original code for both the html and php documents. I’m working with Dreamweaver and I’m not a PHP coder.
Thanks in advance.
[code]jQuery(document).ready(function(){
$(’#contactform’).submit(function(){
var action = $(this).attr(‘action’);
$.post(action, {
name: $(’#name’).val(),
email: $(’#email’).val(),
company: $(’#company’).val(),
subject: $(’#subject’).val(),
message: $(’#message’).val()
},
function(data){
$(’#contactform #submit’).attr(‘disabled’,’’);
$(’.response’).remove();
$(’#contactform’).before(’
’+data+’
’);$(’.response’).slideDown();
if(data==‘Message sent!’) $(’#contactform’).slideUp();
}
);
return false;
});
});
// ]]>
[/code] [php]<?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’,‘message’);
$required = array(‘name’,‘email’,‘message’);
$your_email = "[email protected]";
$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!';
}
}
?>[/php]