Jump to content

Getting Line Breaks in an email!!!


onei0120

Recommended Posts

Okay i have figured out my email problem!!

 

But Now when my email sends all the values are displayed in a straight line kind of like this:

 

20 Joe Blow 123 Fake Street 67 Faketown Fakeville etc.

 

 

and i want to be able to put strings in so when the email send you will see something like this:

 

Age: 20

First Name: Joe

Last Name: Blow

Address: 123 Fake Street

Apt: 67

City: Faketown

Province: Fakeville

 

This is my code:

 

<?php

$to = "*******@****.com";

$subject = "Contest Entry";

$headers = "From: $Email";

$Age = $_REQUEST['age'] ;

$FirstName = $_REQUEST['first_name'] ;

$LastName = $_REQUEST['last_name'] ;

$Address = $_REQUEST['add'] ;

$Apt = $_REQUEST['apt'] ;

$City = $_REQUEST['city'] ;

$Prov = $_REQUEST['prov'] ;

$PostalCode = $_REQUEST['postcode'] ;

$Email = $_REQUEST['email'] ;

$Phone = $_REQUEST['phone'] ;

$Skills = $_REQUEST['skills'] ;

$News = $_REQUEST['accept'] ;

$message =.$Age." ".$FirstName." ".$LastName." ".$Address." ".$Apt." ".$City." ".$Prov." ".$PostalCode." ".$Email." ".$Phone." ".$Skills." ".$News;

$sent = mail($to, $subject, $headers, $message);

if($sent)

{print "Mail Was sent sucessfully"; }

else

{print "We encountered an error sending your mail"; }

?>

Link to comment
https://forums.phpfreaks.com/topic/165014-getting-line-breaks-in-an-email/
Share on other sites

just do like:

 

 

$message="AGE: $age";

$message.="<br>"; // not <br /> i believe

$message.="LOCATION: $location";

$message.="<br>";

 

etc etc

 

All breaks should be in the format <br />, because all opened tags need to be closed according to W3C standards and proper coding syntax.

just do like:

 

 

$message="AGE: $age";

$message.="<br>"; // not <br /> i believe

$message.="LOCATION: $location";

$message.="<br>";

 

etc etc

 

All breaks should be in the format <br />, because all opened tags need to be closed according to W3C standards and proper coding syntax.

 

That is not 100% true. Img tags (Not sure if its limited to only img tags and not everything) should be closed with > and NOT /> if you are using 4.01 or lower.

lol I love how the code they provide to show your code is W3C compliant is:

 

<p>
    <a href="http://jigsaw.w3.org/css-validator/check/referer">
        <img style="border:0;width:88px;height:31px"
            src="http://jigsaw.w3.org/css-validator/images/vcss"
            alt="Valid CSS!" />
    </a>
</p>

 

(notice how the img tag is self-closed) ;)

 

Either way we shouldn't continue discussing this here as it doesn't pertain to the topic.

Duh. Thats why they had:

 

(close the img tag with > instead of /> if using HTML <= 4.01) 

 

Incase you are running HTML <= 4.01 but of course a CSS validator is going to be up to date with everything so they will have the new code. Where do we take this then? Actually, I don't think there is much to say as not all HTML ends with />

 

That code is /only/ compliant with W3C under the condition its HTML > 4.01. If it was HTML <= 4.01 then it wouldn't be compliant. But you might still be right that its always supposed to be <br /> for any line breaks no matter what the HTML version.

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.