【发布时间】:2012-12-07 16:40:55
【问题描述】:
我想以一种安全但通用的方式在 PHP 代码中使用字符串变量,如下例所示。我见过 htmlspecialchars() 但我认为这不是我能得到的最好的。并且 mysql 函数绝对不是解决方案(无论如何,不推荐使用 mysql_real_escape_string 之类的东西)。
你们认为以下情况的最佳解决方案是什么:
$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';
}
谢谢
【问题讨论】:
-
mysql_real_escape_string可能会贬值,但mysqli_real_escape_string不会。 -
您是否担心有人会“注入”您的 if 语句!?
-
为什么?
mysqli_()是外星人的吗? -
这段代码没有什么不安全的地方。您只是比较两个值,这样的操作不会注入任何不好的东西。
-
标题中的“如果”是什么意思?你害怕有人会破解你的 if 语句吗?
标签: php string variables if-statement escaping