Friday, 15 May 2015

php - text area output format -



php - text area output format -

this question has reply here:

how save user-entered line breaks textarea database? 4 answers

when im using text area output format different input format eg:

input :

hi,

hello world.

it outputs :

hi,hello world

what changes want create code format input.

<html> <head> </head> <body> <form method="get" action="textarea.php"> <pre> <textarea name="name"> </textarea> </pre> <input type="submit" name="submit"> </form> <?php if(isset($_get['submit'])) { $name=$_get['name']; echo $name; } ?> </body> </html>

it looks need nl2br in php.

if(isset($_get['submit'])) { $name=$_get['name']; echo nl2br($name); }

also, quentin mentioned, should not echoing user input onto form because ripe xss disaster, hope exercise you.

php html

No comments:

Post a Comment