Admin login page

I am a CS self-taught student and I am trying to make a login system for the admin. When I press the "login" button I am automatically redirected to login-check.php even if my password is wrong (no error message displayed). Do you know how can I fix it? The password has to be correct.

login-page.php

<html> <body> <form name ="login-form action="" method="post" action="logincheck.php"> <input type="text" name="usernamme" placeholder="username" value=""> <input type="password" name="password" placeholder="password" value=""> <button type="submit" name="login" value="submit">Login</button> </form> </body>
</html>

login-check.php

<?php
if(isset($_POST["submit"])){ require("../config/db.php"); $useruid = $_POST["username"]; $password = $_POST["password"]; $sql = "SELECT * FROM users WHERE boss_username=?"; $stmt = mysqli_stmt_init($conn); if(!mysqli_stmt_prepare($stmt, $sql)){ header("Location:login-page.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "ss", $useruid); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if($row = mysqli_fetch_assoc($result)){ $pwdCheck = password_verify($password, $row["boss_password"]); if($pwdCheck == false){ header("Location:login-page.php?error=wrongpassword"); exit(); } else if($pwdCheck==true){ session_start(); $_SESSION["userId"] = $row["$boss_username"]; header("Location:login-page.php?login=success"); exit(); } else{ header("Location:login-page.php?error=wrongpassword"); exit(); } } else { header("Location:login-page.php?error=nouser"); exit(); } }
}
?>
3 Related questions 0 This is Admin Login code in PHP, when i run the code, it does not load the Page that I want 0 Php login panel 0 Admin login form Related questions 0 This is Admin Login code in PHP, when i run the code, it does not load the Page that I want 0 Php login panel 0 Admin login form 1 Login form and accessing pages for admin/users PHP 1 Creating a admin page with php and not sending to admin page going to user account page 0 admin and user login form 0 Problems with a PHP login for Admin 2 PHP-Admin, student LogIn 0 How to login to the Administrator page in PHP 0 Admin and user Login page redirect Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like