title: How to filter any special characters
body: <p>If i have input text in form like this </p>
  
  <pre><code>&lt;form action="add.php" method="post"&gt;
  &lt;input type="text" name="txt" id="txt"&gt;
  &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the add.php code is as following</p>
  
  <pre><code>$sql= "insert into mytable set myname='$txt'";
  executeupdate($sql);
  </code></pre>
  
  <p>My question how to filter any text input from any special characters i just want it only <code>Aa-Zz-1234567890</code> (letters and numbers) only.</p>
  
  <p>Here is my try but i'm not sure will it really filter all special characters or can pass any</p>
  
  <p>i've added in add.php the following code</p>
  
  <pre><code>$cleared = strip_tags($txt);
  $sql= "insert into mytable set myname='$cleared'";
  executeupdate($sql);  // this should clear the name before insert
  </code></pre>
  
  <p>Any suggestions else or better way?</p>