Jump to content

Disabling HTML In user input


RaythMistwalker

Recommended Posts

Ok so I got BB Code working. Now I want to prevent Users from inserting HTML into Posts. I have the following:

 

    $PostText = mysql_escape_string($_POST['replytext']);
    $Replace = Array ('/(<)(.+)(>)/','/(<\/)(.+)(>)/');
    $ReplaceWith = Array ('&LT;\\2&GT;','&LT;/\\2&GT;');
    $PostText = preg_replace($Replace, $ReplaceWith, $PostText);

 

Now If I were to input

<a href=http://phpfreaks.net>Php Freaks</a>

Into a forum reply it would return:

<a href=http://phpfreaks.net>Php Freaks

 

When Checking the database it has:

&LT;a href=http://phpfreaks.net>Php Freaks</a&GT;

 

Any help on solving this?

Link to comment
https://forums.phpfreaks.com/topic/250196-disabling-html-in-user-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.