title: Codeigniter - best practice to sanitize input
body: <p>I would like to know what's the best practice to sanitize user input using Codeigniter. </p>
  
  <p>I understands that CI offers form_validation, such as set_rules. </p>
  
  <pre><code>'set_rules'=&gt;'trim|xss_clean|alpha_numeric|htmlspecialchars'
  </code></pre>
  
  <blockquote>
    <p>"Any native PHP function that accepts one parameter can be used as a
    rule, like htmlspecialchars, trim, MD5, etc."</p>
  </blockquote>
  
  <p>My question now is,</p>
  
  <p>is this enough to protect us from xss, sql injection attacks etc?</p>
  
  <p>what other rules are there that I can apply?</p>
  
  <p>in term of performance, is it costly for us to apply all these rules for all the inputs?</p>
  
  <p>I understand MD5 is a hash funciton, but what happens if you set MD5 as part of the rule?</p>
  
  <p>above that I've added javascript validation as well. Am I on the right track on sanitizing inputs and validating user inputs? Please advice.</p>