Is it possible to pass PHP authorization by code? I also saw authorization in a jQuery ajax request, with ajax authorization is it possible to pass PHP authorization?
I get a page result by ajax request and i got the result, no if I add this code to the top of PHP script :
$valid_passwords = array ("admin" => "123456");
$valid_users = array_keys($valid_passwords);
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
Now it wants to put user and password. Is it possible to put username and password by code? In the ajax request there is something for authorization, can it be used for that?
http://user:[email protected]