mardi 25 août 2020

The script doesn't checking if the credentials are right and doesn't redirect to profile page

The scenario:

  1. User logging using username & password.
  2. The background getting the credentials and the script will check the the username & password equal to the username & password that are stored in the variables "$username,$pass".
  3. If the username & password doesn't match it won't redirect you to profile.php, if it's matching you will be redirected to profile.php.

The Problems:

  1. When I enter the username & password it's just going to check.php which is the script that will check if the credentials are right or not , so it doesn't redirect me to profile.php

Instead of redirecting to http://localhost/loginpage/profile.php it's going to http://localhost/loginpage/checking.php, with a plank page

enter image description here

  1. I'm not sure if the checking function it's right or not , or if it's really checking

Index.php

<!DOCTYPE html>
<html>
<head>
    <title>Professor Albus Dumbledore Secret Door</title>

    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

<form class="login-form"  action="checking.php" method="POST">
  <p class="login-text">
    <span class="fa-stack fa-lg">
      <i class="fa fa-circle fa-stack-2x"></i>
      <i class="fa fa-lock fa-stack-1x"></i>
    </span>
  </p>
  <input type="text" class="login-username" autofocus="true" required="true" placeholder="Username" name="username" />
  <input type="password" class="login-password" required="true" placeholder="Password" name="password" />
  <input type="submit" name="login" value="Login" class="login-submit" />
</form>
<a href="#" class="login-forgot-pass">forgot password?</a>
<div class="underlay-photo"></div>
<div class="underlay-black"></div> 

</body>
</html>

checking.php script:

    <?php

$username = "admin";
$pass = "12345";
#$error = array();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    # code...
    if ($_POST["username"] == $username && $_POST["password"] == $pass) {
        # code...
        header("Location: /profile.php");
        echo "Logged in";
    }


}
?>

Additional Information :

I'm using apache2 server on Ubuntu




Aucun commentaire:

Enregistrer un commentaire