Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more  

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-24-2008, 09:58 AM   #1 (permalink)
baruch menachem
Junior Member
 
Join Date: Mar 2008
Location: Sullivan's Gulch
Posts: 3
Send a message via MSN to baruch menachem Send a message via Skype™ to baruch menachem
Default formated mail

I have a small mail form I am working on. I want it to send the text entered by the person sending the email with the line breaks in, but so far they aren't showing up.

I understood that if I used the wrap="physical" in my HTML description of the field it would pass the line feed through. Like so:
Code:
<textarea cols="60" rows="10" name="message" wrap="physical">Enter your message here</textarea>

Right now, it still passes through as a single line. Is there something I can do on the receiving end to make the line feeds show?
baruch menachem is offline   Reply With Quote
Sponsored Links
Old 03-25-2008, 03:21 PM   #2 (permalink)
psychdev
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: formated mail

newline escape sequence works for me.. if you are using php echo command...

ie)

$msg = "Hello! \n Thank you for signing up!";
psychdev is offline   Reply With Quote
Old 03-26-2008, 12:00 AM   #3 (permalink)
baruch menachem
Junior Member
 
Join Date: Mar 2008
Location: Sullivan's Gulch
Posts: 3
Send a message via MSN to baruch menachem Send a message via Skype™ to baruch menachem
Default Re: formated mail

I found a really good way of solving this on another board. The only thing is, I think I am using the wrong char.


the code looks like this:

Quote:
$message=$_POST["message"];
$newMessage=str_replace(Chr(13),'</p><p>',$message);
$newMessage='<p>'.$newMessage;
$message= $newMessage;
the problem with this is, it takes all the line breaks from the text area and makes them new lines. I want to put in a new line when the author of the message makes a new line. So I think 13 is the wrong number. Especially when I look at the source of my web page after it is done, and the source is formated correctly, but the text on the HTML page is not.
baruch menachem is offline   Reply With Quote
Old 04-06-2008, 01:32 PM   #4 (permalink)
etono
Moderator
 
Join Date: May 2006
Posts: 86
Default Re: formated mail

I am a little unsure about if you are trying to send the textarea input in an email or display it on a webpage, but line breaks in the textarea box are saved as "\n". If you want the line break in an email you may need to add a "\r", so run your message through str_replace function like this:

<?php
$_POST['message'] = str_replace("\n", "\n\r", $_POST['message']);
?>

If you want to display the message to a webpage then you can use the nl2br function like this:

<?php
echo nl2br($_POST['message']);
?>

Hope this helps.
__________________
Jeremy Moseley
My Links: Design Related Blog | Personal Website | Portfolio
etono is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:28 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums