homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

New Line in Email PHP
How do I get new line in message variable

 10:13 pm on Aug 28, 2007 (gmt 0)

I am trying, and have searched four hours, and tried various ways, but nothing seems to work. I have set up a form on my site using flash which sends information to php, which then sends on email of flash input information. I can get this to work fine, however I need to separate the message which is sent as this has various input variables. please see below.

$message = $_POST["address"] . $_POST["postcode"] . $_POST["telephone"] . $_POST["day"] . $_POST["month"] . $_POST["year"] . $_POST["source"] . $_POST["message"] . $_POST["name"];

mail($sendTo, $subject, $message, $headers);


When I get the email through all appears all on one line with no spaces, I need to separate each to a new line. Any help is much appreciated. Thanks.



 12:18 am on Aug 29, 2007 (gmt 0)

Have you tried \n between your post variables?


 6:18 pm on Aug 29, 2007 (gmt 0)

If you need a new line, add the following code at the point you want the line break:
" \n "

For example:
$_POST["address"]." \n ".$_POST["postcode"]." \n " .$_POST["telephone"]." \n ".$_POST["day"].$_POST["month"].$_POST["year"] ." \n ".$_POST["source"]." \n ".$_POST["message"]." \n ".$_POST["name"];

It's important to note that when using \n, you must have it in between double quotes (") not single quotes ('). The newline command will not work if you place it in between single quotes.

Correct: " \n "
Incorrect: '\n'



 8:27 pm on Aug 29, 2007 (gmt 0)

JB, Did what you posted, works a treat. Excellent, many thanks for your help. Alan.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved