PHP blank page after the login -


i'm building cms website. problem after login blank page appears , stays until hit refresh. loads correct menu page , else working correctly except little detail. tips solve this? thanks, code below:

    <?php  session_start();  include_once('../includes/connection.php'); if(isset($_session['logged_in'])) {     //display index     ?>      <html>     <head>         <meta charset="utf-8">         <title>admineng</title>         <link rel ="stylesheet" href="../assets/style.css"/>     </head>          <body>             <div class="container">                 cms - eng                 <ol>                      <li><a href ="add.php">add article</a></li>                     <li><a href ="delete.php">delete article</a></li>                     <li><a href ="logout.php">logout</a></li>                 </ol>             </div>         </body>     </html>      <?php } else {     //display login     if(isset($_post['username'], $_post['password'])) {         $username = $_post['username'];         $password = md5($_post['password']);          if (empty($username) || empty($password)) {             $error = "all fields required!";         }         else {             $query = $pdo->prepare("select * users user_name = ? , user_password = ?");              $query->bindvalue(1, $username);             $query->bindvalue(2, $password);              $query->execute();              $num = $query->rowcount();              if($num == 1) {                 //user entered correct details                 $_session['logged_in'] = true;                  header('location: index.php');                 exit();             }             else {                 //user entered false details                 $error = "incorrect details!";             }         }     }      ?>      <html>     <head>         <title>admineng</title>         <meta charset="utf-8">         <link rel ="stylesheet" href="../assets/style.css"/>     </head>          <body>             <div class="container">                 cms                 <br><br>                  <?php                 if (isset($error)) { ?>                     <small style="color:#aa0000"><?php echo $error; ?></small>                  <?php } ?>                  <br><br>                  <form action="index.php" method="post">                     <input type ="text" name="username" placeholder="username"/>                     <input type="password" name="password" placeholder="password"/>                     <input type="submit" value="login"/>                 </form>             </div>         </body>     </html>      <?php } ?> 

you can't use header after execute html browser. try replace this: header('location: index.php');

with this:

<script>window.location="index.php";</script>


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

netbeans - Remove indent guide lines -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -