Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
New Line in Email PHP How do I get new line in message variable 32alan
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.
Have you tried \n between your post variables? Judah_Ben
If you need a new line, add the following code at the point you want the line break: " \n "
$_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 "
JB, Did what you posted, works a treat. Excellent, many thanks for your help. Alan.