Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.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_Redirect_Login - Fatal编程技术网

Php 当密码有效时,根据用户名将用户重定向到页面

Php 当密码有效时,根据用户名将用户重定向到页面,php,redirect,login,Php,Redirect,Login,我正在尝试创建一个没有MySQL的简单登录系统,这样我的客户就可以登录,并被引导到一个页面,该页面将显示任何文件链接和任何会议的信息 我得到了这个: //If the user is validated and every thing is alright, then grant the user access to the secured account page //otherwise, display error message to the us

我正在尝试创建一个没有MySQL的简单登录系统,这样我的客户就可以登录,并被引导到一个页面,该页面将显示任何文件链接和任何会议的信息

我得到了这个:

    //If the user is validated and every thing is alright, then grant the user access to the secured account page 
                //otherwise, display error message to the user
            if ($vpb_error == '')
            {
                if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
                {
                    echo '<font style="font-size:0px;">completed</font>';
                }
                else
                {
                    echo '<div class="info">Sorry, it seems your information are incorrect and as a result, we are unable to create the required sessions to log you into your account. Please enter your valid account information to proceed. Thanks.</div>';
                }

            }
            else
            {
                echo $vpb_error;
            }
            fclose($vpb_databases);
        }
    }
    else
    {
        echo '<div class="info">Sorry, we could not get your valid username and password to process your login. Please try again or contact this website admin to report this error message if the problem persist. Thanks.</div>';
    }
}
//*********************************************************The login process ends here**********************************************************
如果一切正常,我如何使其重定向到基于用户名的页面,即如果用户名为james,则会将其发送到james.php

干杯
Lewis

我猜下面的if语句就是代码的“成功”分支

编辑

你应该认真清理你的代码;它非常凌乱,看起来过于复杂。你把HTML和PHP混合在一起,虽然不是一个阻碍,但人们通常不赞成。这就是简单易用框架的用武之地。即使你不使用它们,你也应该花一些时间阅读它们,因为它们做了很多正确的事情,而且你在一周内会学到比一生摸索更多的东西。继续前进。。。回到几年前编写的代码,想想‘老兄,我过去很烂!’总是很有趣的


验证用户后,可以使用php头函数


标题'Location:'.$\u会话['username']..php'

我不认为每个用户都需要单独的文件。通常,我会做的是,一旦用户被证明是授权的,您将他们重定向到授权页面,然后该页面将为您的web应用程序呈现应用程序数据


这个页面对于每个人来说基本上都是相同的,您可以使用与该用户相关联的数据来填充它。我想你会有一个链接表和一个会议表,它会将用户id与会议/链接相关联。您可以使用模板引擎,也可以在PHP中使用自己的模板引擎。根据应用程序的深度,您可能希望使用模板引擎来呈现HTML。

是的!非常感谢。谢谢,所以它只是“header”位置:“.$\u SESSION['validusername']”。php′`$_会话['validusername']该变量名听起来像是布尔值true/false,如果它包含您想要的用户名,则为yes。作为旁注:一些旧的浏览器需要一个绝对URI,而不仅仅是文件名。这可能是一个更简单的方法,谢谢你的建议!否则,您必须为每个用户预批处理文件,并且会占用大量内存/存储空间,这不是拥有n层web应用程序的意义所在!
<?php
if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
{
    header('Location: '.$_SESSION['validusername'] . '.php');
}
<?php
// This looks like no error but then...
if ($vpb_error == '')
{
    if(isset($_SESSION['validfullname']) && isset($_SESSION['validusername']) && isset($_SESSION['validemail']) && isset($_SESSION['validpassword']))
    {
        // Mixing HTML directly in a script file
        echo '<font style="font-size:0px;">completed</font>';
    }
    // there is an error here.
    else
    {
        echo '<div class="info">Sorry, it seems your information are incorrect and as a result, we are unable to create the required sessions to log you into your account. Please enter your valid account information to proceed. Thanks.</div>';
    }
}