Jump to content

Archived

This topic is now archived and is closed to further replies.

MoFish

text area new lines?

Recommended Posts

i have a text area on my page, but when i do a new line using return, it is not displaying a new line on the output to screen. how can i successfully use returns so it is displayed in paragraphs for example.

im using the following:

[b]$message = $_POST['messagebox'];[/b]

[b]<textarea name="messagebox" cols="40" rows="5" style="width:300px"></textarea>[/b]

thanks again, mofish

Share this post


Link to post
Share on other sites
When you retrieve it, display it using the nl2br() function:
[code]echo nl2br($message);[/code]

Share this post


Link to post
Share on other sites
Hi,

I have this same problem and am using the nl2br function.

But if someone sends a message with one or more single quotes in it i get the following:

typed in textarea: foo isn't bar

displayed in HTML: foo isn\\\'t bar

For some reason 3 backslashes are added before the quote every time and this happends to every quote in the message.

e.g.

He's it's she's = He\\\'s it\\\'s she\\\'s

How can i stop this properly?

Thanks.

Share this post


Link to post
Share on other sites
[!--quoteo(post=380032:date=Jun 4 2006, 05:27 PM:name=SetLar8)--][div class=\'quotetop\']QUOTE(SetLar8 @ Jun 4 2006, 05:27 PM) [snapback]380032[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi,

I have this same problem and am using the nl2br function.

But if someone sends a message with one or more single quotes in it i get the following:

typed in textarea: foo isn't bar

displayed in HTML: foo isn\\\'t bar

For some reason 3 backslashes are added before the quote every time and this happends to every quote in the message.

e.g.

He's it's she's = He\\\'s it\\\'s she\\\'s

How can i stop this properly?

Thanks.
[/quote]

Try using $message = nl2br(htmlentities($message));


htmlentities($message) should get ride of the \\\ problem.

Share this post


Link to post
Share on other sites
[!--quoteo(post=380045:date=Jun 4 2006, 10:20 PM:name=SetLar8)--][div class=\'quotetop\']QUOTE(SetLar8 @ Jun 4 2006, 10:20 PM) [snapback]380045[/snapback][/div][div class=\'quotemain\'][!--quotec--]
no, that didnt help.

Any other ideas?

Thanks for your help anyway
[/quote]

[code]
<?
$message = nl2br(htmlentities($message));
$goawaybackslash=str_replace("\\\","",$message);
echo $goawaybackslash;
?>

[/code]

Share this post


Link to post
Share on other sites
Hi,

I thought of that but it doesnt work.

It will accept "\\" but not "\\\", try it in dreamweaver.

I really cannot understand it, any more help will be really apreciated.

Share this post


Link to post
Share on other sites
Hi,

Following the above i have found the following:

When i submit the message first time there is only 1 backslash "\'"

But when i pass the variable to another page 2 more are added.

You can check this out here: [a href=\"http://www.maxiehost.com/uk/support.htm\" target=\"_blank\"]http://www.maxiehost.com/uk/support.htm[/a]

When entering the message click send, on the next screen you can see the message with only one backslash for each single quote. when you enter the verification code and submit there are then 2 more added to each single quote.

Share this post


Link to post
Share on other sites
It might be because of "magic_quotes_gpc" setting on in your php.ini. it automatically adds slashes..you can try using stripslashes()....

hth

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.