我正在做一些要发送的项目。但是现在,我将继续使用password_verify方法
//Login Existed User
if (isset($_POST['login'])) {
$email = mysqli_real_escape_string($con, $_POST['email']);
$password = mysqli_real_escape_string($con, $_POST['password']);
//$password = password_verify($con, $password);
$cmmnd = "SELECT * FROM user WHERE email = '$email' AND password ='$password'";
$run = mysqli_query($con, $cmmnd);
if ($run -> num_rows > 0) {
$data2 = $run -> fetch_array();
if (password_verify($password, $data2['password'])) {
header("Location: mainpage.php");
}
}else {
echo "<script>alert('ID or Password Are Wrong!');
window.location= 'user.php'</script>";
}
}
上面有用于登录的脚本。
这里注册码
if (isset($_POST['register'])) {
$fname = mysqli_real_escape_string($con, $_POST['fname']);
$remail = mysqli_real_escape_string($con, $_POST['remail']);
$rpswd = mysqli_real_escape_string($con, $_POST['rpswd']);
$hash = password_hash($rpswd, PASSWORD_DEFAULT);
$sql = "INSERT INTO `user` (`name`, `email`, `password`) VALUES ('$fname', '$remail','$rpswd')";
$data = mysqli_query($con, $sql);
header("Location: regist.php");
}
注册可以,但是现在我无法登录。非常感谢您的帮助。预先谢谢你