note 99512 added to function.str-replace
| From: | gratcypalmaatgmaildotcom at osu1 dot php dot net | Date: | Fri, 20 Aug 2010 19:15:39 +0000 |
| Subject: | note 99512 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171900@lists.php.net to get a copy of this message | ||
<?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
?>
----
Server IP: 202.182.182.183
Probable Submitter: 122.144.3.3
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/99512
Del: integrated -- https://master.php.net/note/delete/99512/integrated
Del: useless -- https://master.php.net/note/delete/99512/useless
Del: bad code -- https://master.php.net/note/delete/99512/bad+code
Del: spam -- https://master.php.net/note/delete/99512/spam
Del: non-english -- https://master.php.net/note/delete/99512/non-english
Del: in docs -- https://master.php.net/note/delete/99512/in+docs
Del: other reasons-- https://master.php.net/note/delete/99512
Reject -- https://master.php.net/note/reject/99512
Search -- https://master.php.net/manage/user-notes.php