Jump to content

E-Mail Form


mR-mONKEY

Recommended Posts

Hello,

 

I am a novice at php and currently trying to edit a e-mail form. I have 2 fields that go to the $message sections of the e-mail, i simply want to insert a <br> inbetween them. Tried everything i could think probaly something really simple any help would be greatly appreciated. my codes below

 

<?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['e_mail']!='' && $_POST['date']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message1'])>30)
{
	$to = '[email protected]';
	$headers = 	'From: '.$_POST['e_mail'].''. "\r\n" .
			'Reply-To: '.$_POST['e_mail'].'' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
	$subject = "MOT Booking";

	$message1 = htmlspecialchars($_POST['message1']);
	$date = htmlspecialchars($_POST['date']);
	$message = "Message: $message1 '<br>' Date: $date";
	if(mail($to, $subject, $message, $headers))
	{
		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/122206-e-mail-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.