note 99512 deleted from security.variables by danbrown
| From: | danbrown@php.net | Date: | Tue, 24 Aug 2010 13:03:35 +0000 |
| Subject: | note 99512 deleted from security.variables by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171978@lists.php.net to get a copy of this message | ||
Note Submitter: gratcypalma at gmail dot com
----
<?php
/*
small anti injection for $_POST and $_GET method
example to use
$str = antiinjection($_POST[str])
*/
function antiinjection($str) {
$banwords = array ("'", ",", ";", "--",
"\"", "%", ">", "<"); // bad words
$str = strip_tags($str);
$str = str_replace ( $banwords, '', $str); // replace badwords to null
return $str;
}
$str = "-- hello guys, nice to <br /> know you --";
echo antiinjection($str);
// result is: hello guys nice to know you
// i know it not better, but it work
?>