Home Tutorial Php Sql Php Sql Sanitize

 
 

Php Sql Sanitize
Posted on: December 10, 2010 at 12:00 AM
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:

Related Tags for Php Sql Sanitize:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.