views:

90

answers:

2

So i have a space where users can input text/html, and it will show up on another page. Sounds pretty simple right. Well this space is a text area - again exactly what you would expect.

But if the user tries to enter in a tag and the tag, then the will close the textbox the next time they load the page (with the previous text inserted by default). How can i let them do this?

+1  A: 

You should escape the text inside the textarea, changing <textarea> to &lt;textarea&gt;. Many languages have a method to do this. In PHP it is called htmlentities.

Note that this will not change how the text shows in the textarea.

Jakob Kruse
+2  A: 

I assume you're using some dynamic backend for displaying the inserted data?

When you output the text in the textarea, escape the output (how you do this varies from language to language, htmlspecialchars works in PHP).

Rexxars