Glenugie Posted January 29, 2010 Share Posted January 29, 2010 So, I have a simple AJAX chat which I run on my website, but this post doesn't concern the AJAX at all, when inserting the message into my database using PHP + MySQL, I use the PHP function strip_tags(). But as this is a chat, this is rather innapropriate, as if a user sends message using a common emoticon (>.< for example), the < will be removed. There are several other common characters which are removed when used in chat, such as the plus sign. Basically, I'm looking for a way to stop users from being able to insert HTML code into chat, without impeding the characters they can use typing a standard message. If there is a way to do it, I figured this would be the place to find out what it was. Even just a point in the right direction would be appreciated. Thanks in advance for any replies ~Glenugie~ Quote Link to comment https://forums.phpfreaks.com/topic/190291-html-tag-stripping-from-a-chat-message/ Share on other sites More sharing options...
mikesta707 Posted January 29, 2010 Share Posted January 29, 2010 you could just use html entities instead of stripping the tags. that way the tags would still be there, but if printed on a web page, wouldn't execute. Quote Link to comment https://forums.phpfreaks.com/topic/190291-html-tag-stripping-from-a-chat-message/#findComment-1003918 Share on other sites More sharing options...
Glenugie Posted January 29, 2010 Author Share Posted January 29, 2010 Thanks, that worked perfectly Quote Link to comment https://forums.phpfreaks.com/topic/190291-html-tag-stripping-from-a-chat-message/#findComment-1003920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.