Get help on this challenge

Debugging13


Please read this explanation before attempting debugging challenges.


This php should log me in when I enter the username "BOB" and the password "bobspass", but it always says "You are not logged in." when I do it. What's wrong?

Here is the file "debugging13-1.php".

<?php
//By ynori7
session_start();
if(isset($_POST['username']) && isset($_POST['password'])){
  if($_POST['username']==="BOB" && $_POST['password']==="bobspass"){
    $_SESSION['login'] = "T";
    $_SESSION['user'] = "BOB";
  }
}
if(!isset($_SESSION['login']) || $_SESSION['login']!=='T'){
  echo "<html>
<body>
<form action='' method='post'>
 Username: <input type='text' name='username'><br/>
 Password: <input type='password' name='password'><br/>
 <input type='submit' name='submit' value='submit'>
</form>
</body>
</html>";
}else{
  header("Location: debugging13-2.php");
  exit();
}
?>


Here is the file "debugging13-2.php".

<?php
//By ynori7
if(isset($_SESSION['user'])){
  echo "<p>Welcome {$_SESSION['user']}.</p>\n";
  $date = gmdate("M d Y H:i:s");
  echo "<p>The current date and time is $date GMT.</p>\n";
}else{
  echo "<p>You are not logged in.</p>\n";
}
?>

Downloadable source code can be found here and here.


You must be logged in to play.



Challenge by ynori7.