0

I am trying to load my start page (php) on localhost with xampp. As long as I keep the file an html document (saved as start.html) it is showing up but as soon as I save it as a php file (in order to execute the $_SESSION['id'] it fails to load the file (basically an infinite loading process but no errors showing up. Here is my code. Any help is highly appreciated. Thanks

<?php
session_start();?>
<html>
  <head>
    <title>
      I am a login project
    </title>
    <meta charset="utf-8">
    <link rel="stylesheet" href='style.css' type="text/css">
  </head>
  <body>
    <form method="post" action="login.php">
      <input type="text" placeholder="uid" name="Username">
      <input type="password" placeholder="Password" name="pwd">
      <button type="submit" name="submit">LOGIN</button>
    </form>
    <br>
    <?php
    if(isset($_SESSION['id'])){
      echo $_SESSION['id'];
    }
  ?>

      <form method="post" action="signup.php">
        <input type="text" placeholder="first" name="first">
        <input type="text" placeholder="last" name="last">
        <input type="text" placeholder="uid" name="Username">
        <input type="password" placeholder="Password" name="pwd">
        <button type="submit" name="submit">SIGN_UP</button>
      </form>
      <br>
      <form method="post" action="logout.php">
        <button type="submit" name='logout'>LOGOUT</button>
      </form>
  </body>
</html>
Muten_Roshi
  • 541
  • 2
  • 7
  • 16

1 Answers1

0

session start should happen before any output. there is a space before your opening php tag

Maarten van Middelaar
  • 1,691
  • 10
  • 15