gpt4 book ai didi

php - mysql_real_escape_string 会导致问题吗?

转载 作者:行者123 更新时间:2023-11-29 09:14:06 26 4
gpt4 key购买 nike

好的。所以我做了一个表格。如果我在从表单中检索到的变量 $usrname (是的,拼写正确)上输入 mysql_real_escape_string ,它会返回我的另一个变量 $verifyfalse。看看:

<html>
<body>
<?php

session_start();

include("mainmenu.php");

$usrname = $_POST['usrname'];
$password = sha1($_POST['password']);

$con = mysql_connect("localhost", "root", "Y0U_C@NT_H@NDLE_THE_TRUTH!");
if(!$con){
die("Unable to establish connection with host. We apologize for any inconvienience.");
}

mysql_select_db("users", $con) or die("Can't connect to database.");

$select = "SELECT * FROM `data` WHERE usrname = '$usrname' and
password = '$password'";
$query = mysql_query($select);
$verify = mysql_num_rows($query);

if($verify==1){
$_SESSION["valid_user"] = $usrname;
header("location:index.php");
}
else{
echo "Wrong username or password. Please check that CAPS LOCK is off.";
echo "<br/>";
echo "<a href=\"index.php\">Back to login</a>";
}

mysql_close($con);

?>
</body>

如果我将mysql_real_escape_string放入注册表单或登录表单中,它会返回$verifyfalse。怎么了?

最佳答案

请确保 PHP 设置中的“Magic Quotes”已关闭。解释了如何禁用它here .

关于php - mysql_real_escape_string 会导致问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4675737/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com