mR-mONKEY Posted March 6, 2009 Share Posted March 6, 2009 Hi all iam bit of a newbie when it comes to php, I have a contact form which e-mails me a massage, name, and e-mail address. Iam after adding a few extract fields which will be in the message part of the e-mail for example i also want telephone number just wondering how i can add it to the message part would it be something like $message = htmlspecialchars($_POST['message']) SOMETHING TO SEPRATE IT HERE htmlspecialchars($_POST['tel']); This is the code as you can see ive added the tel feild to the top of the if statement just wondering where i put the other bit to get it to appear in the massage? <?php error_reporting(E_NOTICE); function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } if($_POST['first_name']!='' && $_POST['last_name']!='' && $_POST['tel']!='' && $_POST['e_mail']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>30) { $to = '[email protected]'; $headers = 'From: '.$_POST['e_mail'].''. "\r\n" . 'Reply-To: '.$_POST['e_mail'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Hello! I'm testing my new ajax email that I got from roscripts.com"; $message = htmlspecialchars($_POST['message']); if(mail($to, $subject, $message, $headers)) {//we show the good guy only in one case and the bad one for the rest. echo 'Thank you '.$_POST['first_name'].'. Your message was sent'; } else { echo "Message not sent. Please make sure you're not running this on localhost and also that you are allowed to run mail() function from your webserver"; } } else { echo 'Please make sure you filled all the required fields, that you entered a valid email and also that your message contains more then 30 characters.'; } ?> Thanks Jon Link to comment https://forums.phpfreaks.com/topic/148271-contact-form/ Share on other sites More sharing options...
WolfRage Posted March 8, 2009 Share Posted March 8, 2009 Read this entire post, and if you still have questions get back to me and I will help you out. http://www.phpfreaks.com/forums/index.php/topic,240974.msg1129162.html#msg1129162 Link to comment https://forums.phpfreaks.com/topic/148271-contact-form/#findComment-779304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.