-1

hi i am doing a web and after i check if a session is set for see if is loged or not the body is not working of the html, the code:

<?php 
 session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if( !isset($_SESSION["username"]) ){




        echo "<p id='errors'>Por favor, loguese, si no se redirecciona haz click <a href='log.php'>aqui</a></p>";

        exit();


}else{
    exit();
};
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Login</title>
    <link rel="stylesheet" href="custom.css">

</head>

<body>
   test
</body>
</html>

as you can see the word "test" should be on the body but in the web there isnt what can i do ?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Pachi
  • 17
  • 6

3 Answers3

0

The exit() function closes the output buffer. So nothing behind it is executed or displayed.

Ouput buffer control

Jirka Vrba
  • 367
  • 2
  • 6
0

You use exit(); in both cases of your if/else condition. This stops the output before the HTML part even begins...

Johannes
  • 64,305
  • 18
  • 73
  • 130
0

Put only this

if( !isset($_SESSION["username"]) ){

    echo "<p id='errors'>Por favor, loguese, si no se redirecciona haz click <a href='log.php'>aqui</a></p>";

    exit();

}

without else

Kuba Zabielski
  • 146
  • 2
  • 10