gpt4 book ai didi

php - 重定向 - 登录后重定向到上一页?

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

我需要某人的专业知识。一旦用户登录....如果他们尝试返回登录页面,我希望他们被重定向到另一个 php 页面。现在我的用户仍然可以登录,但也可以返回到登录表单。

<?php

if(isset($_POST['login'])){

session_start();

$password = $_POST['pass'];
$email = $_POST['email'];

$user_pass= md5($user_pass);

$check_user = "select * from userss where user_pass='$password' AND user_email='$email'";

$run = mysql_query($check_user);

if(mysql_num_rows($run)>0){

$_SESSION['email']=$email;

echo "<script>window.open('welcome.php','_self')</script>";
}
else {
echo "<script>alert('Email or password is incorrect!')</script>";
}

}

?>

最佳答案

此类问题已得到解答。请参阅How to make a redirect in PHP?

在提供任何页面之前,您已经检查了用户的登录状态。对吗?

if (logged_in){
header("Location: http://example.com/myOtherPage.php");
die();
}

关于php - 重定向 - 登录后重定向到上一页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29908234/

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