bciprianp Posted February 8, 2013 Share Posted February 8, 2013 Hi, i have a php contact form that is managed with ajax, but i cant get it to work properlly. Here is the contact form on my demo site: http://www.bcpdemo.8...om/contact.html I receive the name and the message but not the email, instead of email i get a subject filled with the name. Thanks alot for the help guys. here is how it looks in my yahoo inbox: here is how it looks when i enter the message: and here is the php script: 1.config_php <?php define("WEBMASTER_EMAIL", 'yourname@email.com'); ?> 2.contact.php include 'config.php'; error_reporting(E_ALL ^ E_NOTICE); $post = (!empty($_POST)) ? true : false; if ($post) { include 'functions.php'; $name = stripslashes($_POST['name']); $email = trim($_POST['email']); $message = stripslashes($_POST['message']); $error = ''; // Check name if (!$name) { $error .= 'Please enter your name.<br />'; } // Check email if (!$email) { $error .= 'Please enter your e-mail adress.<br />'; } if ($email && !ValidateEmail($email)) { $error .= 'Invalid e-mail adress !<br />'; } // Check message (length) if (!$message || strlen($message) < 1) { $error .= "Please enter your message."; } if (!$error) { $subject = "your subject"; $messageform = stripslashes($_POST['message']); $message = "Subject: " . $subject . "\n\nFrom: " . $name . "\n\nMessage: " . $messageform; $mail = mail(WEBMASTER_EMAIL, $subject, $message, "From: " . $name . " <" . $email . ">\r\n" . "Reply-To: " . $email . "\r\n" . "X-Mailer: PHP/" . phpversion()); if ($mail) { echo 'OK'; } } else { echo '<div class="notification_error">' . $error . '</div>'; } } ?> 3.functions.php <?php function ValidateEmail($email) { $regex = '/([a-z0-9_.-]+)'. # name '@'. # at '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains '.'. # period '([a-z]+){2,10}/i'; # domain extension if($email == '') { return false; } else { $eregi = preg_replace($regex, '', $email); } return empty($eregi) ? true : false; } ?> Thanks alot for your help guys. Quote Link to comment https://forums.phpfreaks.com/topic/274208-php-contact-form-help/ Share on other sites More sharing options...
denno020 Posted February 8, 2013 Share Posted February 8, 2013 Have you tried putting just the email after From: in your 4th parameter to the mail function? It looks like you're trying to achieve something like this: From: Joe < joe@email.com Maybe, yahoo doesn't like that? I would remove $name and and "<" sign, leave just email after From:, and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/274208-php-contact-form-help/#findComment-1411176 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.