Php Sql Sanitize
This example illustrates how to implement the sanitized filter in php application.
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:
