Page 1 of 1

comment box

Posted: Sat Nov 13, 2010 4:23 am
by amirbwb
hello, i'm trying to create a comment, so everything works fine but i have a prob:
When i enter the comment in the comment box and write:
"
test test 123
test
test
"
in the page wich shows the comment this will appear "test test 123 test test" with to "return new line"
but actually i pressed "enter" 2 times
so ishould write the comment like this:
"
<p>test test 123</p>
<p>test</p>
<p>test</>
"

thank for your helps ..

Re: comment box

Posted: Sat Nov 13, 2010 4:29 am
by lorenzo-s
Type the comment the normal way, then print out the comment with:

Code: Select all

echo nl2br(htmlentities($comment));
I recommend you to read the docs for these functions and something about security and input escaping:
http://php.net/manual/en/function.nl2br.php
http://php.net/manual/en/function.htmlentities.php
http://www.mt-soft.com.ar/2007/12/21/th ... -mistakes/