TL;DR
This guide shows how to quickly disable password authentication in a basic PHP application for testing or development purposes. Warning: This is insecure and should only be used in controlled environments!
Steps
- Locate the Authentication Code
- Comment Out or Remove Password Check
- Ensure Login Success
- Test the Bypass
- Important Security Note
- Never use this method in a production environment. It completely compromises the security of your application.
- This is intended for local development and testing only, where security isn’t a concern.
- Always restore the original authentication code when you are finished testing.
Find the section of your PHP code that handles user login. It will typically involve checking a username and password against stored credentials.
The simplest way to bypass password authentication is to comment out or delete the lines of code responsible for verifying the password. For example, if your code looks like this:
if ($password == $stored_hash) {
// Login successful
} else {
// Login failed
}
Change it to:
// if ($password == $stored_hash) {
// Login successful
// } else {
// Login failed
// }
// Always log the user in for testing.
Or, more directly:
$login_successful = true; // Bypass password check. DO NOT USE IN PRODUCTION!
Modify the code to always set a successful login flag. This might involve setting a session variable or redirecting the user.
session_start();
$_SESSION['user_id'] = 1; // Example: Log in as user ID 1.
header('Location: welcome.php');
Refresh your login page and attempt to log in with any username (and any password). You should now be logged in without entering a correct password.

