-1

I am having an issue with my login screen for my website I am making. When I go to my login screen it is blank and says that there was an internal server error. Can anyone help?

here is my script:

<?php
  session_start();
  $user="customer";
  $pass="customer";
  if (isset($_SESSSION["logged_in"] && $_SESSION["logged_in"] == true)){
    header("Locataion: form.php");
  }
  if (isset($_POST["username"]) && isset($_POST["password"])){
    if ($_POST["username"] == $user && $_POST["password"] == $pass){
      $_SESSION["logged_in"] = true;
      header("Locataion: form.php");
    }
  }
 ?>
<html lang="en">
<body>
  <form class="login" method="post" action="login.php">
    Username:<br>
    <input type="text" id="username" name="username" required><br>
    Password:<br>
    <input type="password" id="password" name="password" required><br>
    <input type="submit" label="Login">
</form>
</body>
</html>
aynber
  • 22,380
  • 8
  • 50
  • 63
Kipycoo
  • 3
  • 1

1 Answers1

0

Information about the problem:

In IF(), you check if the variable is set with isset(), however, isset() must encompass your variable. the problem is that closing isset() is not correct it should end just after your first variable $_SESSSION["logged_in"]

Solution:

Replace:

if (isset($_SESSION["logged_in"] && $_SESSION["logged_in"] == true)){
  header("Location: form.php");
}

By :

if (isset($_SESSION["logged_in"]) && $_SESSION["logged_in"] == true){
  header("Location: form.php");
}

Good luck !

Jeremy
  • 96
  • 1
  • 1
  • 8