Home Tutorial Php Sql Php Sql Sanitize

 
 

Share on Google+Share on Google+
Php Sql Sanitize
Posted on: December 10, 2010 at 12:00 AM
Advertisement
This example illustrates how to implement the sanitized filter in php application.

Php Sql Sanitize

This example illustrates how to implement the sanitized filter in php application.

Filter knows two kinds of filter:

  • sanitizing filters
  • logical filters

The sanitizing filters: 

  • Allow or disallow characters in a string
  • Does not care about the data format
  • It always returns a string

 

Source Code of sanitize.php 

<html>
  <head><title>Sanitization</title></head>
  <body>
    <form action="<?=$PHP_SELF?>" method="post" >
      Enter your name: <input name="name">
      <input type="submit" name="submit" value="Go">
    </form>
  </body>
</html>

<?php
  $name="";
  if (!filter_has_var(INPUT_POST, 'submit')) {
    echo "form";
  }
  $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS);

  if (is_null($name)) {
    echo "The 'name' field is required.<br />";
  else {
    echo "Hello $name.<br/>";
  }
?>

Download Source Code

 

Output:

Advertisement

Related Tags for Php Sql Sanitize:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 10, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com