SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    new line on php mail from customer end

    please i am trying to make the message show on newline as the customer type it, but i am getting /r/n between each line and also trying to make the $body .= $_SESSION['username']; appear on a separate line the code is below

    PHP Code:
    $body .= $_SESSION['username'];
        
    $body .= $message;
        
    $to $email;
       
    $subject "copy of your notification"
    $headers "From: [email]noti@r.co.uk[/email]\r\n";  
    $headers  .= 'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'Bcc:noti@r.co.uk' "\r\n";
    mail($to,$subject,$body,$headers);
        }
        }  
    ?> 
    HTML Code:
    <p>
    <form action='notification.php' method='Post' class='rl'>
        <div>
        <label for='message' class='fixedwidth'>Message</label>
        <textarea name="message" rows ="7" cols="40" id="message"></textarea>
        </div>
    
        <div class='buttonarea'>
                <p>
                <input type='submit' name='notify' value='Notify'>
                </p>
                </div>
                </p>
    </form>

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2008
    Location
    The Netherlands
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you with the $message?

    AS long as you are sending html mail you can choose to use <br /> instead of newlines. Maybe with the function nl2br();

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    @RvanD85 the $message
    should be the message from the customer
    i tried this
    PHP Code:
    $body .= $_SESSION['username'];
        
    $body .= nl2br($message); 
    but i got same result

  4. #4
    SitePoint Addict tom8's Avatar
    Join Date
    Mar 2012
    Location
    New Jersey
    Posts
    310
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Remove \r and see if it works.

    This article explains why if it does.

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,097
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    You could try something like this:

    PHP Code:
    $user $_SESSION['username'];

    $body 
    $user.'
    '
    .$message
    or

    PHP Code:
    $user $_SESSION['username'];

    $body 
    "$user\n" .  
    "$message"
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  6. #6
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    @ralph i used
    PHP Code:
    $body $_SESSION['username']. "<br>"
             
    nl2br($_POST['message']); 
    and its working


Bookmarks

Posting Permissions

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