Jump to content


Photo

text area new lines?


  • Please log in to reply
8 replies to this topic

#1 MoFish

MoFish
  • Members
  • PipPipPip
  • Advanced Member
  • 210 posts

Posted 04 June 2006 - 09:09 PM

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:

$message = $_POST['messagebox'];

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

thanks again, mofish

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 June 2006 - 09:13 PM

When you retrieve it, display it using the nl2br() function:
echo nl2br($message);

Legend has it that reading the manual never killed anyone.
My site

#3 SetLar8

SetLar8
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 June 2006 - 09:27 PM

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.

#4 Daguse

Daguse
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 04 June 2006 - 09:32 PM

[!--quoteo(post=380032:date=Jun 4 2006, 05:27 PM:name=SetLar8)--][div class=\'quotetop\']QUOTE(SetLar8 @ Jun 4 2006, 05:27 PM) View Post[/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.

#5 SetLar8

SetLar8
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 June 2006 - 10:20 PM

no, that didnt help.

Any other ideas?

Thanks for your help anyway

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 04 June 2006 - 10:42 PM

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

Any other ideas?

Thanks for your help anyway
[/quote]

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


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 SetLar8

SetLar8
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 June 2006 - 11:49 PM

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.

#8 SetLar8

SetLar8
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 June 2006 - 12:41 AM

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.

#9 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 05 June 2006 - 06:42 AM

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

hth
Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users