Line Break Madness!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmitchell
    New Member
    • Jun 2007
    • 10

    Line Break Madness!

    I've been trying to work out this very simple thing for hours now and I wonder if you can help.

    My form submits the value of textarea, then takes the value and emails it in a plaintext email. Problem is the no matter what I do, I cannot get the line breaks in the email.

    [CODE=php]

    $msg_text = $_GET['msg_text'];
    $email = "me@gmail.c om";
    $subject = "My Subject";
    $headers = 'From: me@me.com' . "\r\n" .
    'Reply-To: me@me.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    mail($email,$su bject,$msg_text ,$headers);
    echo "done";
    [/CODE]

    The form looks like this:[code=html]
    <form action="FILE_NA ME" method="GET">
    <textarea name="msg_txt" cols="50" rows="50"></textarea>
    <input type="submit" value="go">
    </form>[/code]

    Something like nl2br is not an option because I don't want html output and I simply can't figure out why the line breaks are being taken out of this string.

    Any help would be greatly appreciated!
  • eboyjr14
    New Member
    • Apr 2007
    • 27

    #2
    I think I remember that you should use the function stripslashes in the message body var...

    Comment

    • eboyjr14
      New Member
      • Apr 2007
      • 27

      #3
      Instead of using $_GET vars, you should use $_POST since the user cannot see what they sent and they can send a really long message if they want. GET vars has a limited amount of info.

      Comment

      • jmitchell
        New Member
        • Jun 2007
        • 10

        #4
        Thanks for the replies. Neither of those does the trick, though.

        Comment

        • ben808
          New Member
          • Jun 2007
          • 2

          #5
          using $_GET url encodes the form field contents I guess - so a newline becomes: %0D%0A

          so if you need to use $_GET then use:

          $message = urldecode($_GET["msg_text"]);

          Comment

          • jmitchell
            New Member
            • Jun 2007
            • 10

            #6
            I'm embarassed to say I didn't mention that there was javascript involved. Once I used javascript escape to encode the url, the get worked fine. Thanks for putting up with me.

            Comment

            Working...