Hi all, I have a php contact form on my site which works great. The only issue I have is that when I recieve an email via the contact form, it displays my hosting address in the sender address, as seen below
dectecc1@web95.justhost.com
I want it to display the users email from when they inputted it on on the form. So it really should be reading
john@example.com
here is the header scripts
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(function(){
$('#sendemail').submit(function(){
var action = $(this).attr('action');
$.post(action, {
name: $('#name').val(),
email: $('#email').val(),
subject: $('#subject').val(),
message: $('#message').val()
},
function(data){
$('#sendemail #submit').attr('disabled','');
$('.response').remove();
$('#sendemail').before('<p class="response">'+data+'</p>');
$('.response').slideDown();
if(data=='Message sent!') $('#sendemail').slideUp();
}
);
return false;
});
});
// ]]>
</script>
here is the form
<form action="contact.php" method="post" id="sendemail">
<blockquote>Alternatively if you would like to email us you can complete the form below and We will reply promptly.</blockquote>
<ol><li>
<label for="name">Name (required)</label>
<input id="name" name="name" class="text" />
</li><li>
<label for="email">Email Address (required)</label>
<input id="email" name="email" class="text" />
</li><li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text" />
</li><li>
<label for="message">Your Message</label>
<textarea id="message" name="message" rows="8" cols="50"></textarea>
</li><li>
<input type="image" name="imageField" id="imageField" src="images/submit.jpg" class="send" />
<div class="clr"></div>
</li></ol>
</form>
and here is the contact.php code
<?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 = "john@example.com";
$email_subject = "Website Message: ".$_POST['subject'];
$email_content = "Website Message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'subject') {
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 much appreciated.
cheers
Steve