gpt4 book ai didi

PHP 登录页面错误

转载 作者:行者123 更新时间:2023-11-29 08:04:20 24 4
gpt4 key购买 nike

我的代码:

<html>
<head>
<title>Logging in......</title>
<?php

function decryptString($q){
$cryptKey = 'jamie20020410';
$qDecoded = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,md5($cryptKey),base64_decode($q),MCRYPT_MODE_CBC,md5(md5($cryptKey))),"\0");
return($qDecoded);
}

#login verify
$user_name = $_GET['name'];
$user_pwd = $_GET['pwd'];

$db=mysqli_connect("mysql17.000webhost.com","xxx","xxx","xxx");
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($db,"SELECT * FROM LoginInfo");

while($info = mysqli_fetch_array( $result )){
$dbu_name = decryptString($result['LoginName']);
if ($user_name == $dbu_name){
$dbu_pwd = decryptString($result['LoginPwd']);
if ($user_pwd == $dbu_pwd){
$loggedin = 1;
}
}
}

if ($loggedin != 1){
print("<script>alert('Wrong username or password!');</script>");
}else{
print("<script>alert('Correct login!');</script>");
}

?>
</head>
</html>

这不起作用。登录数据库没有问题。

显示的消息:

Fatal error: Cannot use object of type mysqli_result as array in /home/a7593238/public_html/login/login.php on line 23

在数据库中:

LoginName | LoginPwd
test | test

仅此而已。
有什么帮助吗?

最佳答案

您想在 while 循环内使用 info,即包含数据的数组。

$result['LoginName'] 更改为 $info['LoginName'] 等等。

关于PHP 登录页面错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23025521/

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