Hello,
I'm pretty new to PHP still, so bear with me if this is an obvious mistake, but the PHP e-mail form I created won't send the information through to me, the recipient. From the website all the forms are set up and work, the error messages work, and it successfully sends the message...except I never get it.
Below is the PHP code written:
<?php
$emailSubject = 'contact';
$webMaster = 'example@example.com' ;
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 = "james@example.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 'Your message has been successfully sent! I will get back to you as soon as possible.';
} else {
echo 'ERROR!';
}
}
?>
And this is the accompanying HTML code written:
<form action="contact.php" method="post" id="contactform">
<ol>
<li>
<label for="name">your 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="company">Company Name</label>
<input id="company" name="company" class="text" />
</li>
<li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text" />
</li>
<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/btn_send_message.gif" />
<a href="https://www.sitelock.com/verify.php?site=www.cr-portfolio.com" target="_blank"><img id="sl_shield_image" alt="SiteLock" title="SiteLock" border="0" hspace="50"src="http://shield.sitelock.com/shield/www.cr-portfolio.com" oncontextmenu="alert('Copyright 2009 SITELOCK.COM. All rights reserved.');return false;"/></a>
</li>
</ol>
</form>
Thanks in advance. I've been going in circles for ages trying to figure this out on my own, going through FAQ's, forums, and anything else I could find on the internet with no success. If desired you can see it live HERE.