Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP froms - line breaks between body elements?

    Hello all,

    Although basic, I seem to be struggling with laying out a PHP based web form. It executes to the desired inbox no problem; however, it’s not very legible as all the fields are bunched together without even a character break. The structure of the code is as follows:

    <?php
    $to = "enquiries@blahblahblah";
    $subject = "Employer Registration Form";
    $headers = "From: " . $_POST['emailAddress'];
    $body = $_POST['contactPerson'];
    $body .= $_POST['homePhone'];
    $body .= $_POST['mobile'];
    $body .= $_POST['fax'];
    $body .= $_POST['bestTimeContact'];
    $body .= $_POST['totalStaff'];
    $body .= $_POST['kitchenStaff'];
    $body .= $_POST['floorStaff'];
    $body .= $_POST['staffTurnover'];
    $body .= $_POST['comisChef'];
    ini_set("sendmail_from", " enquiries@blahblahblah ");
    mail($to,$subject,$body,$headers);
    ?>

    How can I initiate a line break between each body element so as to make it easier to read once submitted?

    Thanks in advance for any assistance.

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    \n is the character code for a linebreak, so you'd use:
    PHP Code:
    $body.=$_POST['blah']."\n"

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent, thank you very much – didn’t expect such a timely response.

    I hope to be of assistance myself sometime, though given my knowledge…….

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •