Page 1 of 1

disabling html in forms

Posted: Wed Dec 18, 2002 4:33 am
by SublicK
Hey,

I'm working on a simple forum script, and I want to disable html in the posts. I have been using str_replace() to change the characters '<' '>' etc. to their text code. Is there an easier way to do this?

Code: Select all

function format_content ($content)
   &#123;
     $content = str_replace ("&",  "&",  $content);
     $content = str_replace ("<",  "<",   $content);
     $content = str_replace (">",  ">",   $content);
     $content = str_replace (""", """, $content);
     $content = str_replace ("'",  "'", $content);
     $content = str_replace ("!",  "&#033;", $content);
     $content = str_replace ("|",  "&#124;", $content);
     $content = str_replace ("<br>", "\n", $content);

     return $content;
   &#125;
If there isn't another way, are these all the characters I should look out for? What else should I be careful of?

Thanks

Posted: Wed Dec 18, 2002 4:36 am
by Takuma

Posted: Wed Dec 18, 2002 4:40 am
by SublicK
wow, that was quick...

ok, that's deffiently a easier way, thanks