Forum Moderators: coopster

Message Too Old, No Replies

Text area new line security issues.

Allowing users to make new lines without compromising database security.

         

AndyRox

9:16 pm on Mar 11, 2007 (gmt 0)

10+ Year Member



Hi all,

I am not sure if there has been a thread about this already posted, I had a look through the php section and could not find anything so if there is and I have missed it then please let me know.

ELSE
{
^LOL

I have a <textarea> on an html form and have used the code below in the processing script:

$msg_text = mysql_real_escape_string(nl2br($_POST["msg_text"]));

Where $msg_text is what has been entered into the <textarea> and past to the processing script. This displays the $msg_text when required with new lines working fine but this method also allows users to use html in their posts to completely modify the appearance of the page when displaying the message. I need a way of writing a message in the <textarea> so that when the user presses enter it makes a new line on the output of the message WITHOUT processing any other html code or compromising the database security.

Any suggestions?
Thanks
Andy

cameraman

12:27 am on Mar 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$msg_text = mysql_real_escape_string(nl2br(strip_tags [us2.php.net]($_POST["msg_text"]),"\n"));