zoukankan      html  css  js  c++  java
  • 防止SQL注入

     1 function checkStr($username){
     2         //自定义字符串规则
     3 } 
     4 
     5 function checkLogin($username,$password){
     6         
     7         $password = md5($password);
     8 
     9         $username = addslashes($username);//转义
    10 
    11         $sql = "select * from {$this->getTableName()} where u_username='{$username}' and u_password='{$password}'";
    12 
    13         return $this->db_getRow($sql);
    14 }

    大概分两步,先自定义字符串规则如去除空格特殊符号等等,再使用转义,后面的语句一定要加上单引号。

  • 相关阅读:
    2月11日
    亚特兰蒂斯
    080215 晴
    2月9日
    2月6日
    2月10日
    080208 晴(0,50)
    关于春晚
    (15,50)
    恍然大悟
  • 原文地址:https://www.cnblogs.com/VRGamer-006/p/8440284.html
Copyright © 2011-2022 走看看