敏感词过滤

/*第一种方式*/
$sql="select value from dede_sysconfig where varname='cfg_notallowstr'";

    $mingan=$link->query($sql);

    $arr = $mingan->fetch_row();
    //数组元素组合成字符串
    $list="/".implode("|",$arr)."/i";

    if(preg_match($list,$username,$matches)){ 
        echo "";
    } else { 
        $sql= "insert into dede_member2 (userid,uname,email,pwd,mobile,jointime) values('$username','$username','$email','$hashpwd','$mobile','$jointime')";
        // echo "出错" . $sql . "
" . $conn->error; //插入数据库
if(!mysqli_query($link,$sql)){ // echo strlen($hashpwd); // echo "出错" . $sql . "
" . $conn->error;
echo ""; } else{ echo ""; } }

你可能感兴趣的:(敏感词过滤)