Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
PHP SQL Sanitize 
 

PHP SQL Sanitize is a kind of filter which is used to allow or disallow characters in a string.

 

PHP SQL Sanitize

                         

PHP SQL Sanitize is a kind of filter which is used to allow or disallow characters in a string.

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 strings
  • Does not care about the data format
  • It always returns a string

Understand with Example

The Tutorial illustrate an example from 'PHP SQL Sanitize'. To understand the example we create a sanitize.php embeds a html page, which allows the user to enter the name in the text field. When accepting data from a user, any data at all should be sanitized before making its way. To sanitize the data we make use of php code begins with <?php and end with ?>.  For name field, there is no type to validate against, it can be filtered to remove HTML tags. The conditional if ($ name) evaluate to true if the $_POST['name'] variable was set and passed the filter. This will print the filtered version and the original version..

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:

                         

» View all related tutorials
Related Tags: sql mysql c string sed char return character cte to e use from left in m tr s urn rac

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.