PHP Email form
Hi there.
I am trying to use a html form to send a PHP email but I am having some problems when I enter the message in the text area. The messages that I send have line breaks in but instead of doing a line break it shows the <br /> and it also shows the \n and \r tags. Is there any way to stop them from showing but still use the line breaks.
Thanks in advance
Cameron
Related Article: Form To Send Html Email With Attachment
is a solved PHP discussion thread by simsim123 that has 2 replies, was last updated 2 years ago and has been tagged with the keywords: mail(), php.
doctorphp
Junior Poster in Training
67 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Maybe you can give a snippet of your code?
Yeah sure,
The Form
<select name="email">
<option value="0">- - SELECT - -
<?php echo $options; ?>
</select>
<br /><br />
Subject: <input type="text" name="subject" size="60"/><br />
Message:<br />
<textarea name="message" cols="70" rows="8" ></textarea><br />
<input type="submit" name="send" value="Send" />
</form>
The PHP
$headers = "From: $from";
$to = $_POST['email'];
$to = stripslashes($to);
$to = mysql_real_escape_string($to);
$subject = $_POST['subject'];
$subject = stripslashes($subject);
$subject = mysql_real_escape_string($subject);
$message = $_POST['message'];
$message = nl2br($message);
$message = mysql_real_escape_string($message);
$submit = $_POST['submit'];
mail($to, $subject, $message, $headers);
Any help would be much appreciated.
doctorphp
Junior Poster in Training
67 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 2 Years Ago by
Daiva