所以我需要为毕业项目制作一个完整的登录系统。我已经在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";
}
}
}
答案 0 :(得分:0)
<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
if method =“ POST” 然后在PHP中使用$ _POST
if method =“ GET” 然后在PHP中使用$ _GET
如果不确定是GET还是POST方法
使用
调试在您的login.php中
echo "This is Post method";
var_dump($_POST);
echo "This is Get method";
var_dump($_GET);