簡體   English   中英

php重定向標頭有困難,我是否正確?

[英]having a hard time with php redirect header, am i doint it right?

我在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中調用,並在/ home / a2502890 / public_html / includes中定義第5行的/init.php

我正在嘗試為我的學校項目創建一個簡單的聊天網站

改變這個

function check_login($username,$enroll)

function check_login()

我不知道為什么不使用它們時會有這些參數。

您已經定義了一個名為check_login的函數,其中包含兩個必需參數。 $ username和$ enroll。

但是在第3行(頂部的代碼)中,您使用的是check_login()而沒有傳入這些參數,因此是問題所在。

根據我在這里看到的內容,您似乎需要從check_login中刪除$ username和$ enroll。 例如:

function check_login() {
   ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM