Creating line breaks in output?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Lou Ghaddar
Forum Newbie
Posts: 9
Joined: Tue Feb 17, 2004 12:33 pm

Creating line breaks in output?

Post by Lou Ghaddar »

I have made an email form in Flash that outputs to a PHP file to then be mailed to an email address. Everything works but the output in the email is all on one line. I would like to be able to make a line break so that each output would be on its own line.
The FLash form has seven fields that are all user input fields. (i.e. firstName, lastName, phone, altPhone, address, and commentBox.) I would like each one to appear in the email on it's own line.

The code is as follow:

<?php
$sendTo = "lou@selway.umt.edu";
$subject = "Design Turf Career Oppurtunities Reply";
$headers = "From: " . $_POST["firstName"]. "','".$_POST{"lastName"];
$headers .= "<" . $_POST["email"] .">\r\n";
$message = "First Name: " . $_POST["firstName"]. "','".$_POST["lastName"]. "','".$_POST["phone"]. "','".$_POST["altPhone"]. "','".$_POST["email"]. "','".$_POST["address"]. "','".$_POST["commentBox"];

mail($sendTo, $subject, $message, $headers);
?>
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

To make a line break just add

Code: Select all

\r\n
where you want the carriage returns

Doc
Lou Ghaddar
Forum Newbie
Posts: 9
Joined: Tue Feb 17, 2004 12:33 pm

Post by Lou Ghaddar »

Great, thank you very much. :wink:
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

You actually already have it in the code after $headers

:wink:
Lou Ghaddar
Forum Newbie
Posts: 9
Joined: Tue Feb 17, 2004 12:33 pm

Post by Lou Ghaddar »

I have tried it, and when I put it in the code no longer processes anything. Does it need to be in quotations, or brackets? And where exactly in the code should it be placed? I did this and it doesn't work.

$message = "Name: " . $_POST["firstName"]. " ". $_POST["lastName"].">\r\n" "Phone: ". $_POST["phone"];
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

$message = "Name: " . $_POST["firstName"]. " ". $_POST["lastName"].">\r\n" "Phone: ". $_POST["phone"];

change to:

$message = "Name: " . $_POST["firstName"]. " ". $_POST["lastName"].">\r\nPhone: ". $_POST["phone"];
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Illusionist wrote:$message = "Name: " . $_POST["firstName"]. " ". $_POST["lastName"].">\r\n" "Phone: ". $_POST["phone"];

change to:

$message = "Name: " . $_POST["firstName"]. " ". $_POST["lastName"].">\r\nPhone: ". $_POST["phone"];
change to

Code: Select all

<?php
$message = "Name: " . $_POST['firstName']. " ". $_POST['lastName'].">\r\nPhone: ". $_POST['phone'];
?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

same thing only the " to ' but that doesn't make a difference
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

security reasons + neater code
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

agree with the neator code, but what about the security issues... how so?
Lou Ghaddar
Forum Newbie
Posts: 9
Joined: Tue Feb 17, 2004 12:33 pm

Post by Lou Ghaddar »

I will give it a shot. Thanks for the tips everyone. :)
Lou Ghaddar
Forum Newbie
Posts: 9
Joined: Tue Feb 17, 2004 12:33 pm

Post by Lou Ghaddar »

Perfect! It works perfectly. Thank you all so much. :D
Post Reply