PDA

View Full Version : Verifying blog comments


noartistname
08-15-2009, 07:09 PM
Hello!

I would like to know if it possible to check comments in blog somehow, so they won't contain any HTML characters (like <a href="12345"></a>)? I'm working on simple blog for my needs and when I save comment like described above, I see link, but I don't want to allow users to do so.

Thanks.

_Aerospace_Eng_
08-15-2009, 07:13 PM
You can use strip_tags to remove most html. You can also use htmlentities to convert any left over stuff to unusable code.

noartistname
08-15-2009, 07:22 PM
You can use strip_tags to remove most html. You can also use htmlentities to convert any left over stuff to unusable code.

Yes, strip_tags do that. However I don't understand why MySQL table doesn't have some function that allows to output everything like either text, or HTML.

_Aerospace_Eng_
08-16-2009, 09:05 AM
Why would it? Its only storing what you put in it. The formatting and how it looks would be done with your server side language. Mysql has some functions but none that can do what you want. http://dev.mysql.com/doc/refman/5.1/en/string-functions.html