Page 1 of 1

disabling HTML tags in textarea?

Posted: Thu Nov 27, 2008 12:10 pm
by alex7900
I want to know how to disable html tags in a textarea, for example if you type this:

Code: Select all

<Hey whats up?>
it wont show anything when i submit it since the browser will detect it as an html command

its for a comment system, and Im no professional with php :P
this is what im using:

Code: Select all

 
<form action='blahblah.blahblah'>
<textarea cols="43" rows="11" name='blahblahblah'></textarea>
<input type='submit'>
</form>
and it is recieved, in the next page, and printed like this:

Code: Select all

$text=S_POST['blahblahblah'];
echo "$text";
that WILL display the text, but it will let the user use html tags, and that will definitly lead to someone playing with the layouts, or even using php :banghead:
im not asking for BBcode or anything(unless you know how! :o ), but i just want to let the user use html tags without actually using html

EDIT:
also, i wanna know how to automatically detect linebreaks, because in the editor even if you press enter a million times, all the text will be on one line :(

Re: disabling HTML tags in textarea?

Posted: Thu Nov 27, 2008 12:39 pm
by Syntac

Re: disabling HTML tags in textarea?

Posted: Thu Nov 27, 2008 12:47 pm
by draco
You should also check out the strip_tags() function. You can also only allow certain tags through.

Re: disabling HTML tags in textarea?

Posted: Fri Nov 28, 2008 4:01 pm
by alex7900
thanks, that helped :D
i used:
htmlspecialchars()
and
str_replace() - which i found by playing around in that site :P