Jump to content

Recommended Posts

hello. I have a message board of my website, but it allows people to use html tags. they can make a right mess of it using massive fonts all all different colours. Im seeking a way to prevent this from occouring. I found the following code on a different website however am not really sure how to call it from my php document.

[code]
function removeHTML($strToFilter) {
    $strToFilter = str_replace(">", "& g t;",$strToFilter);
    return str_replace("<", "& l t;",$strToFilter);
}
[/code]

Im using the following code to add to the database, but really would like it to try to prevent the tags and stuff if possible. please note, this is a snipit of code not the full whack. im just assuming the tag check will be somewhere here, but dont know exactly how to do it.

does anyone mind showing me how i can use the function on $data and $subject please?

Thanks MoFish

[code]
if ($data == "" || $subject == "") {
    $errormsg = 'Please Fill In All The Fields Above';
    $success = '<a href="index.php?page=forumpost"><b>Try Again</b></a>';
    
} else {
                    
    if (mysql_query($query)){
            
        if (mysql_query($topicquery)){
                $errormsg = 'added to topic database!';
                $success = 'added';
        } else {
                $errormsg = 'problem adding topic!';
                $success = 'failed';
        }
[/code]
Link to comment
https://forums.phpfreaks.com/topic/7828-using-a-function/
Share on other sites

There are two functions builtin to PHP that you should look at[list][*][a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]htmlentities()[/a][*][a href=\"http://www.php.net/strip_tags\" target=\"_blank\"]strip_tags()[/a][/list]You can used them either when you put the data into the database or when you write the data back to the screen.

Ken
Link to comment
https://forums.phpfreaks.com/topic/7828-using-a-function/#findComment-28537
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.