douyousu9691 2012-12-07 16:40
浏览 22

用于“if”的PHP转义字符串[关闭]

I would like to use string vars on a safe but universal way for using them in PHP code such as the example below. i've seen htmlspecialchars() but i don't think it's the best i can get for what i need. and mysql functions are definetly not a solution (things like mysql_real_escape_string are deprecated anyway).

what do you guys think would be the best solution for following situation:

$password = $_POST['password'];
$password_check = $_POST['password_check'];

//make $password and $password_check safe

if($password != $password_check)
{
    $errors[] = 'The two passwords did not match';
}

thanks

  • 写回答

2条回答 默认 最新

  • duangan9251 2012-12-07 16:44
    关注

    So what if mysql_() is about to get deprecated? PHP has other options like mysqli_() and PDO

    $password = mysqli_real_escape_string($connect, $_POST['password']);
    $password_check = mysqli_real_escape_string($connect, $_POST['password_check']);
    
    //make $password and $password_check safe
    
    if($password != $password_check) {
        $errors[] = 'The two passwords did not match';
    }
    

    mysqli_() Reference

    评论

报告相同问题?