General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 20th, 2003, 02:49 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Forms problem

Hi,
I am having trouble with a form textbox...a simple matter? Not for me. I am trying to create a textbox to stores the data - using php, mysql. No problems here yet. Where I have problems is storing the data so it keeps it's "returns" and "tabs", etc. I haven't even gotten to bold, underlined, etc. I'm not trying to create a wysiwyg editor, just a text box that stores text, then I have another page that will display the text. Currently I am doing this for an online newsletter. I works. The teacher types in the forms and the output is okay, but without any "returns" or <br> in html.

How do I do this?

BBforums have a cool feature for writing forum posts, as does this. This post doesn't delete the "returns". How complicated is this textbox? I'd love to view this code... just for the way it keeps the "returns".

I tried using a function to no edit function but I found it could yield some strange results, like very long lines if the user never added a return, just let the line go on and on, it ignored the restricted output textbox...

Anyway, any help would be appreciated.
__________________
bow wow!

Reply With Quote
  #2  
Old February 20th, 2003, 06:03 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Lets assume you have given your textarea a name of "sometext", and you will be posting the form variables.

PHP Code:
print nl2br($_POST["sometext"]); 


The above code should do the trick.
If you had output the contents between
<pre></pre> blocks, you would have noticed
that it worked without nl2br.

The difference is that in html a new line character
does not show up.

only <br> or <br /> shows up as a new line.
nl2br will add the <br> to the newline character which
allows html to see a newline.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old February 20th, 2003, 06:16 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
all nl2br does is
replace \r\n or \n to <br> tags

You should also check out php's other text formatting functions at php.net

There are functions that will remove html tags, etc

Reply With Quote
  #4  
Old February 21st, 2003, 10:15 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Quote:
Originally posted by Ben Rowe
all nl2br does is
replace \r\n or \n to <br> tags


According to the php manual, I took it that it doesn't replace the newlines. The excerpt is:

Quote:
Returns string with '<br />' inserted before all newlines.


What that means to me is that on windows \r\n is preserved but <br /> is appended to it. Mac uses \r and Unix uses \n, and the same appeding is applied to those OSes also.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Forms problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway