Problem php header location redirect blank page

Hello everyone I have a problem with header location redirect me to a blank page without making me see the code and the browser does not report any error I work locally with exampp

<?php
class UserController
{
    public $username = '';
    private $logged   = false;
    private $usermodel = '';

    public function __construct()
    {   $this->usermodel = new UserModel();
        session_start();
        

        if ($_SERVER['REQUEST_METHOD']=='POST' && isset($_GET['action'])&& $_GET['action']== 'login' ){
            $username = (isset($_POST['username']))? $_POST['username'] :false ;
            $password = (isset($_POST['password']))? $_POST['password'] :false ;
            var_dump($username,$password);
            if ($username !=false && $password !=false && $this->usermodel->checkLogin($username, $password)){

                $this->username =$username ;
                $this->logged = true ;

                $_SESSION['username']= $username ;
                $_SESSION['logged']= true ;
                $_SESSION[ 'message' ]  = 'Login effettuato correttamente';
            }else{
                $_SESSION[ 'message' ]  = 'Errore con il login; riprovare!';
            }
        }
        elseif (isset($_GET['action'])&& $_GET['action']== 'logout'){
            unset($_SESSION['username']);
            unset($_SESSION['logged']);
            $_SESSION[ 'message' ] = 'Logout effettuato correttamente';
        }
        elseif (isset($_SESSION['username'])&& isset($_SESSION['logged'])){

            $this->username = $_SESSION['username'] ;
            $this->logged = true ;
        }
        elseif(($_SERVER['REQUEST_METHOD']=='POST' && isset($_GET['action'])&& $_GET['action']== 'registra' )){
            
            $username = (isset($_POST['username']))? $_POST['username'] :false ;
            $password = (isset($_POST['password']))? $_POST['password'] :false ;
            $repassword = (isset($_POST['repassword']))? $_POST['repassword'] :false ;
            $nome_reale = (isset($_POST['nome_reale']))? $_POST['nome_reale'] :false ;
            $email = (isset($_POST['email']))? $_POST['email'] :false ;
            
            

            if ($username !=false && $password !=false && $repassword !=false && $nome_reale && $email !=false
               && $this->usermodel->Registration($username,$password,$repassword,$nome_reale,$email) )
            {
                $this->username =$username ;
                $this->logged = true ;

                    
                $_SESSION['username']= $username ;
                $_SESSION['logged']= true ;
                $_SESSION[ 'message' ]  = "registrazione effettuato correttamente benvenuto $username";
            }
        }
        $this->redirectToProperArea();
    }
    
    public function logged(){
        return $this->logged ;
    }
    public function redirectToProperArea(){
        
        $script_file = basename( $_SERVER[ 'SCRIPT_NAME' ] );

        if ( $this->logged() && $script_file == 'login.php' ) {
            
            ob_start();
            header('Location:/index.php' );
            die();
        } 
        elseif ( !$this->Logged() && ( $script_file == 'index.php' && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] != 'index' && $_GET[ 'action' ] != 'detail' && $_GET[ 'action' ] != 'logout' ) ) {
           
            ob_start();
            header('Location:/login.php');
            die();
        }
        elseif ( $this->logged() && $script_file == 'registra.php' ) {
            
            ob_start();
            header('Location:views/benvenuto.php');
            die();
        }
    }
}

Thanks for your help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.