title: PHP: Allow users to make posts with certain tags
body: <p>Users on my site can post news items. But right now, it's all honor system as far as HTML goes.</p>
  
  <pre><code>function postNewsItem($subject, $body, $userid){
    $time = time();
    $subject = mysql_real_escape_string($subject);
    $body = mysql_real_escape_string($body);
    $q = "INSERT INTO news (subject, body, userid) VALUES ('$subject', '$body', '$userid')";
    $result = mysql_query($q, $this-&gt;connection);
    return 1;
  }
  </code></pre>
  
  <p>I want users to be able to link to images, build tables, bold their words, etc etc, but I don't want them to be able to link to malicious scripts and what-not. I know there are ways to escape HTML from user input, but is there a way to do that while allowing certain tags?</p>