The scenario:
- User logging using username & password.
- 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".
- 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:
- 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
- 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
 
    
" . $u . "
"; echo "" . $p . "
"; } the "else" is under the second "if", and this is the results : " . $u . ""; echo " " . $p . " "; } } ?> – maksim lev Aug 25 '20 at 09:33