title: How to validate a string in PHP + MYSQL?
body: <p>I'm using PDO with prepare statement.</p>
  
  <p>I'm using Javascript to encrypt text from html textarea, decrypt in PHP, adding some text and i re-encrypt data before write it in the DB.</p>
  
  <p>I'm using PHP to decrypt data from db and put it in HTML5 pages.</p>
  
  <p>Often the content are the result of HTML encoded text.</p>
  
  <p>addslashes, htmlentities and preg_replace...can i validate / filter data in the best way for me?</p>
  
  <p>Whats the difference between to validate and to filter data?</p>
  
  <p>I have no experience in security. please help me to find the best way for my application.</p>
  
  <p>thanks in advance</p>