C
C
Chesterfield252021-07-04 22:40:31
PHP
Chesterfield25, 2021-07-04 22:40:31

How to fix an error in the paths?

My project structure
60e20c6c5e26c272518206.png

I am in the xfcategory.php file along the path adminpanel/xfcategory.php I get the
error:
: Cannot modify header information - headers already sent by (output started at C:\OpenServer\domains\xmonitoring.demo\adminpanel\xfcategory.php: 10) in
C:\OpenServer\domains\xmonitoring.demo\config\function.php on line 17

17 line from file \config\function.php Complete function code

header("Location:../adminpanel");

if (isset($_SESSION["username"])) {
    header("Location:../adminpanel");
}


I am not strong in php. Can there be an error if I have sessions connected in function.php
// Authorization to the admin panel
if (isset($_SESSION["username"])) {
    header("Location:../adminpanel");
}


And in file \adminpanel\xfcategory.php like this

<?php
session_start();
if (!isset($_SESSION["username"])) {
    header("Location:../adlogin");
}
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2021-07-04
@sHinE

The problem is not with the paths, but that your script C:\OpenServer\domains\xmonitoring.demo\adminpanel\xfcategory.php on line 10 is already outputting something to the browser. And the headers should go before any output to the browser, which php tells you about.

S
Spartak (Web-StyleStudio), 2021-07-04
@Spartak-2205

https://www.php.net/manual/en/function.header.php

Remember that the header() function can only be called if no data has been sent to the client yet. That is, it should come first in the output, there should not be any HTML tags, empty lines, etc. before it is called...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question