Created
April 16, 2020 05:11
-
-
Save SiddheshNan/dbda4f3326a398c525694fedc7926603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(0); | |
session_start(); | |
$valid_passwords = array ("user" => "pass"); | |
$user = $_SERVER['PHP_AUTH_USER']; | |
$pass = $_SERVER['PHP_AUTH_PW']; | |
$valid_users = array_keys($valid_passwords); | |
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]); | |
if (!$validated) { | |
header('WWW-Authenticate: Basic realm="Please Enter Your Credentials"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
session_destroy(); | |
die ("Not Authorized"); | |
} | |
else | |
{ | |
echo "logged in!"; | |
//other logic here.. | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment