Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-02-2007, 02:14 PM $_POST form problem
cbeaudin's Avatar
Extreme Talker

Posts: 158
Name: cbeaudin
Location: Proud to be Canadian
Trades: 1
I have a form that asks to enter one or more paragraphs

The problem is when you submit it, if you have a line break, it adds "rn" instead of "/r/n"

I am not cleaning the variable at all... here is a simple version of the script

PHP Code:
if(!isset($_POST[submit]))
    {
    echo 
"<form method='post' action='http://www.cnotecreations.com/webmanager/mairsfamily/index.php'>";
    
    echo 
"<textarea name='paragraph' rows='7' cols='35' />$getmain3[paragraph]</textarea>";

//$getmain3[paragraph] is defined earlier in the code

    
    
echo "<input type='submit' name='submit' value='Submit' />";
    echo 
"</form>";
    
    }
    else
    {
    echo 
$_POST['paragraph'];
    } 
So for exapmle if i type in the following:
"Line
Beak
Test"

The output ($_POST['paragraph']) is equal to:
"linernbreakrntest" with no slashes

Thanks in advance for any help.
__________________
- cbeaudin
cbeaudin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-03-2007, 01:51 AM Re: $_POST form problem
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
If you echo this back to browser then it's no wonder that there are no line breaks. In html line breaks are not simply \r\n but <br />. Either use nl2br() or wrap the output into <pre></pre> to keep line breaks.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 10-03-2007, 09:44 AM Re: $_POST form problem
cbeaudin's Avatar
Extreme Talker

Posts: 158
Name: cbeaudin
Location: Proud to be Canadian
Trades: 1
The original code updates that field to a database and use BBCode later on to insert it into the html, but the BBCode does not work when the line break is defined as "rn" why is there no slashes?

The only reason i am printing it to the screen is so i can play around with some stuff and see if the problem is fixed without having to check the database.
__________________
- cbeaudin

Last edited by cbeaudin; 10-03-2007 at 09:45 AM..
cbeaudin is offline
Reply With Quote
View Public Profile
 
Old 10-03-2007, 10:38 AM Re: $_POST form problem
Super Talker

Posts: 130
Trades: 0
have you tried mtishetsky suggestion of nl2br()
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to $_POST form problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13189 seconds with 12 queries