Created
February 12, 2022 07:24
-
-
Save songwutk/c4ce3a4ffd3f6e12f9dfba5a0e77b7ae to your computer and use it in GitHub Desktop.
PHP header authentication
This file contains hidden or 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 | |
// POSTMAN Authorization | |
// Basic Auth | |
// Fill => Username & Password | |
$username="api-user"; | |
$password="ajck_[99HkJC"; | |
// phpinfo(); | |
// print_r($_SERVER); | |
if ($_SERVER["PHP_AUTH_USER"]==$username && $_SERVER["PHP_AUTH_PW"]==$password) | |
{ | |
header('Content-Type: application/json; charset=utf-8'); | |
echo json_encode(["data"=>"Welcome"]); | |
} | |
else | |
{ | |
header('HTTP/1.0 403 Forbidden'); | |
echo json_encode(["data"=>"Access denied"]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment