Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP登录脚本-每个用户需要一个单独的登录页_Php - Fatal编程技术网

PHP登录脚本-每个用户需要一个单独的登录页

PHP登录脚本-每个用户需要一个单独的登录页,php,Php,我目前上传了一个简单的php登录脚本,在这里提供 这个登录包附带1个sql文件和简单的PHP代码,一旦登录,用户就可以访问logged_-in.PHP,否则它将保持在not_-logged_-in.PHP(相当基本) 它还带有一个功能正常的寄存器页(非常简单) 我需要在哪个页面上进行编辑,以及我将使用什么代码进行编辑,以便user1获得与user2不同的登录页 非常感谢 编辑: 我想将user1的登录页面输入到sql表中,并获取它,以便在用户登录后,它会转到该链接所在的任何位置。鉴于您的简单脚本

我目前上传了一个简单的php登录脚本,在这里提供

这个登录包附带1个sql文件和简单的PHP代码,一旦登录,用户就可以访问logged_-in.PHP,否则它将保持在not_-logged_-in.PHP(相当基本)

它还带有一个功能正常的寄存器页(非常简单)

我需要在哪个页面上进行编辑,以及我将使用什么代码进行编辑,以便user1获得与user2不同的登录页

非常感谢

编辑:


我想将user1的登录页面输入到sql表中,并获取它,以便在用户登录后,它会转到该链接所在的任何位置。

鉴于您的简单脚本,有几种方法可以做到这一点

1) 更改logged_in.php以检查登录的用户,并根据一些地图或您计划如何处理这些用户,将其转发到个性化登录页面

2) 更改log_in函数以返回用户应转发到的页面,而不是布尔值(此处假设)。接收页面随后将根据用户是否成功失血转发用户

3) 更改登录功能,将用户转发到该用户的相应页面,无论该页面是登录页面还是失败页面


在您的情况下,我可能会选择#3,因为它是最直接的实现。

在您对用户进行身份验证的登录脚本页面中,您可以在身份验证后将user1带到与user2不同的登录页面。一种方法是在sql本身中存储用户身份验证后将要去的页面名,并在登录时检索该页面名。然后在
标题中使用它('location:这已经发布了两次。我们不知道如何帮助您,但如果您知道该场景,但我们需要至少看到一部分代码,用于重定向登录到您的登录页的用户。不要创建多个帐户并问同一个问题。这正是我想做的,我想知道的是,如何制作脚本转到user1的登录页?当前代码如下,但我希望它为用户从sql行中获取:。编辑:我已将其添加到原始帖子中。对不起,如果我的sql表中的列是登录页,那么这是否应替换页名?是否还应替换loggedin\u userid,应该是..sql中的用户名?我仍然得到一个空白页。是的。我刚才向您展示了示例。您需要根据自己的名称更改值(您使用的名称)。:)刚刚在你的帖子中添加了我的代码版本。对不起。我不明白为什么它仍然为空。顺便说一句,登录页列在SQL中应该是什么属性?我已将其设置为文本。对不起,我是SQL的新手。我想可能需要链接主键。请让我知道。@user3654802请在你的问题中添加任何其他代码,而不是添加到a答案:)
// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {
// the user is logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are logged in" view.
include("views/logged_in.php");

} else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
include("views/not_logged_in.php");
// ... ask if we are logged in here:

if ($login->isUserLoggedIn() == true) {

$page = "SELECT page_name from users WHERE userid='$loggedin_userid'";
$query = mysql_query($page);
$page_name = mysql_result($query,0);
if($page_name){ header("location:'$page_name'"); //or include($page_name);}

} else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
include("views/not_logged_in.php");
}
// include the configs / constants for the database connection
require_once("config/db.php");

// load the login class
require_once("classes/Login.php");

// create a login object. when this object is created, it will do all login/logout stuff automatically
// so this single line handles the entire login process. in consequence, you can simply ...
$login = new Login();

// ... ask if we are logged in here:

if ($login->isUserLoggedIn() == true) {

$page = "SELECT landing_page from users WHERE userid='$user_id'";
$query = mysql_query($page);
$landing_page = mysql_result($query,0);
if($landing_page){ header("location:$landing_page"); }

} else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
include("views/not_logged_in.php");
}