473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Line Break Madness!

jmitchell
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $msg_text = $_GET['msg_text'];
  3. $email = "me@gmail.com";
  4. $subject = "My Subject";
  5. $headers = 'From: me@me.com' . "\r\n" .
  6.    'Reply-To: me@me.com' . "\r\n" .
  7.    'X-Mailer: PHP/' . phpversion();
  8. mail($email,$subject,$msg_text,$headers);
  9. echo "done";
  10.  
The form looks like this:
Expand|Select|Wrap|Line Numbers
  1. <form action="FILE_NAME" method="GET">
  2. <textarea name="msg_txt" cols="50" rows="50"></textarea>
  3. <input type="submit" value="go">
  4. </form>
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!
Jun 22 '07 #1
5 1824
I think I remember that you should use the function stripslashes in the message body var...
Jun 23 '07 #2
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.
Jun 23 '07 #3
Thanks for the replies. Neither of those does the trick, though.
Jun 23 '07 #4
ben808
2
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"]);
Jun 26 '07 #5
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.
Jun 29 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roland Dalmulder | last post by:
Hello all, In my PHP script I put a text file into a string. Part of that string is read, changed and removed. The while loop continuest to extract the next part of the string. This goes all...
6
by: Jonathan | last post by:
I want to save textarea contents to a mysql database with the paragraph breaks intact without having to type paragraph or break tags in HTML. How can I do that. So far, although it occurs naturally...
6
by: R | last post by:
Hello everybody! I'm newbie to JavaScript and I have a basic question. I have X and Y coordinates of A and B points. How can I draw a line connecting A and B? thanks in advance cheers
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
3
by: Yansky | last post by:
Hi, I've looked through the tutorial on w3cschools.com, but I'm still uncertain as to the difference between using break and using return. If I have a simple "for" loop that I want to stop if a...
10
by: Itaichuk | last post by:
Hi I read in several CSS tutorials that block-level elements, such as <div& <pare rendered with an implicit line break before and after. I set to test this out using the following HTML: I...
1
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to...
16
by: lovecreatesbea... | last post by:
It takes mu so time to finish this C source code line count function. What do you think about it? / ******************************************************************************* * Function ...
7
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.