Jump to content

removing \r\n from form generated email


Thumper

Recommended Posts

Tried the nl2br() function but still getting the same result.  e.g. if i enter...

Hi,

Love the site,

Dave.

...and hit enter, I get "Hi,\r\nLove the site,\r\nDave." in my email.

 

The code is quite simple :

 

if (isset($_POST['submit']))	 // Handle the form.
{
		// Check for an email address.
	if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) {
		$e = escape_data($_POST['email']);
	} else {
		$e = FALSE;
		echo '<p><font color="red" size="+1">Please enter a valid email address!</font></p>';
	}

		// Check for a subject line.

		if (!(trim($_POST['subject'])==""))
		{
			$s = escape_data($_POST['subject']);
		}
		else
		{
		$s = FALSE;
		echo '<p><font color="red" size="+1">Please enter a valid subject line!</font></p>';
		}

		// Check for text in the comments box.

		if (!(trim($_POST['comments'])==""))
		{
			$c = escape_data($_POST['comments']);
		}
		else
		{
		$c = FALSE;
		echo '<p><font color="red" size="+1">Please enter your comments!</font></p>';
		}

	#############################################
		if ($e && $s && $c)	#	everything is okay...
	#############################################
		{
			$MailTo=$adminEmail;
			if (mail($MailTo, $s, nl2br($c), "From: $e"))
		}
}

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.