gpt4 book ai didi

php - 无法登录(MySQL、PHP)

转载 作者:行者123 更新时间:2023-11-29 16:02:13 25 4
gpt4 key购买 nike

所以我需要为我的毕业设计制作一个完整的登录系统。我已经在 mysql 上创建了一个完美运行的数据库。登录的注册部分可以工作,但如果我尝试使用刚刚创建的帐户登录,则无法工作。大多数时候我都会收到错误“密码/电子邮件错误”,而其正确性如何?

提前致谢!

   <?php
include("config.php");
session_start();

$email =$_POST['email'];
$password =$_POST['password'];
if(empty($email))
{

exit();

}else {
$stmt =mysqli_stmt_init($db);
$sql = "SELECT * FROM users WHERE email=?;";

if(!mysqli_stmt_prepare($stmt, $sql))
{

echo"No data";
}else
{
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($result))
{
$combicheck = password_verify($password,$row['password']);
if($combicheck == false)
{

echo"Password / email is wrong";
exit();
}else if($combicheck == true){
session_start();
$_SESSION['password'] = $row['password'];
header('Location: index.html');
echo"Logged in";
}

}else
{
echo"Failed";
}
}
}

最佳答案

<form action="login.php" method="POST">
<input type="text" name="" /> <br />
<input type="password" name="" /> <br />
<input type="submit" name="submit" value="login" />
</form>

在 php.ini 文件中将 display_errors=Off 更改为 display_errors=On

如果方法=“POST”然后在 php 中使用 $_POST

如果方法=“GET”然后在 php 中使用 $_GET

如果您不确定是 GET 还是 POST 方法

使用调试

在你的login.php中

echo "This is Post method";
var_dump($_POST);
echo "This is Get method";
var_dump($_GET);

关于php - 无法登录(MySQL、PHP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56094334/

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