So we can do anti-injection.

Source: Internet
Author: User
So you can do anti-injection?

function Defend_xss ($val) {
Return Is_array ($val)? $val: Htmlspecialchars ($val);
}

function GPC ($name, $w = ' GPC ', $default = ', $d _xss=1) {
Global $curr _script;
if ($curr _script==admincp) {
$d _XSS = 0;
}
$i = 0;
for ($i = 0; $i < strlen ($w); $i + +) {
if ($w [$i] = = ' G ' && isset ($_get[$name])) return $d _XSS? DEFEND_XSS ($_get[$name]): $_get[$name];
if ($w [$i] = = ' P ' && isset ($_post[$name])) return $d _XSS? DEFEND_XSS ($_post[$name]): $_post[$name];
if ($w [$i] = = ' C ' && isset ($_cookie[$name])) return $d _XSS? DEFEND_XSS ($_cookie[$name]): $_cookie[$name];
}
return $default;
}



$test = GPC (' Test ', ' P ', ')
$userid = @ $db->result_first ("Select userid from user where username= ' $test '");
.... The following code omits
?>


Can you do anti-injection?

Share to:


------Solution--------------------
No!
You do not have any treatment for special characters '
------Solution--------------------
Single quotes, and so on, you can consider using MySQL and other functions of their own conversion
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.