Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating next lines in html

Explorer ,
Sep 17, 2012 Sep 17, 2012

My php contact form is working properly but whenever my client receives an email from the form, the email looks very disorganized because all of the contact information that the user has submittted, comes in one line.

Here is my php code

                $To = "fakemail";

                $Subject = "fake message";

                $From = "fake user";

                $Message = "Name: " . $Name. "Email " . $Email. "Phone" . $Phone. "Options" . $Options. "Comments"  . $Comments;

                $Headers = "From: ". $from . "<" . $to. ">\r\n";  

                $Headers .= "Reply-To: " . $email_text . "\r\n"; 

                $Headers .= "Return-path: ". $email_text;

                $result = mail($To, $Subject, $Message, $Headers);

I would like to add the "\n" after each  .$Name,  .$Email, etc variable so when my client receives the message it will come out like

Name: Bob

Email: fake@email.com

Phone: 123345

etc....

Thanks in advanced

TOPICS
Server side applications
978
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 17, 2012 Sep 17, 2012

More than line breaks, a table would look best. Here's the code:

    $mailBody = '<table border="1">';

    $mailBody .= '<tr>';

    $mailBody .= '<td>Name :</td><td>'.$fullName.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Title :</td><td>'.$title.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Company :</td><td>'.$company.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>City :</td><td>'.$city.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>State :</td><td>'.$state.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Postal Code :</td><td>'.$postal.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Country :</td><td>'.$country.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Phone Number :</td><td>'.$phoneNo.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>E-Mail :</td><td>'.$eMail.'</td>';

    $mailBody .= '</tr><tr>';

    $mailBody .= '<td>Message :</td><td>'.$message.'</td>';

    $mailBody .= '</tr>';

    $mailBody .= '</table>';

   

   

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2012 Sep 19, 2012

Sudarshan Thiagarajan wrote:

More than line breaks, a table would look best. Here's the code:

A table won't work unless the headers also set the Content-type to text/html. By default, the mail() function uses plain text.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2012 Sep 19, 2012

David, I overlooked OP's headers and failed to mention this in my reply. Sorry about that and thanks for pointing it out!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2012 Sep 23, 2012
LATEST

David, Now I fully understand,  Thanks!

Sudarshan, still, I do appreciate your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2012 Sep 19, 2012

Very simple:

$Message = "Name: " . $Name. "\r\n\r\nEmail: " . $Email. "\r\n\r\nPhone: " . $Phone. "\r\n\r\nOptions: " . $Options. "\r\n\r\nComments: "  . $Comments;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines