使用php重定向标题很难,我做得对吗?

时间:2014-03-19 20:29:45

标签: php mysql redirect

我在index.php @line 3

中有这段代码
    if(check_login()==true){
header('location: chat/chat.php');

和我的init.php中的这个

    <?php
    session_start();
    require('const.php');
    require($db_file);
    function check_login($username,$enroll) {
        if(isset($_SESSION['username']) && isset($_SESSION['enroll'])) {
            return true;
        }
        else
            return false;
    }
    function get_username() {
        return $_SESSION['username'];
    }
    function get_enroll() {
        return $_SESSION['enroll'];
    }
    ?>

它总是在我的页面中说明这一行并且无法继续登录 警告:缺少check_login()的参数1,在第3行的/home/a2502890/public_html/index.php中调用,并在第5行的/home/a2502890/public_html/includes/init.php中定义

我试图为我的学校项目创建一个简单的聊天网站

2 个答案:

答案 0 :(得分:1)

更改此

function check_login($username,$enroll)

function check_login()

我不知道你不使用它们时为什么会有这些参数。

答案 1 :(得分:1)

您已经定义了一个名为check_login的函数,其中包含两个必需参数。 $ username和$ enroll。

然而,在第3行,顶部的代码,你使用check_login()而没有传递这些参数因此问题。

根据我在这里看到的内容,您似乎需要从check_login中删除$ username和$ enroll。 E.g:

function check_login() {
   ...
相关问题