webForumDet fria alternativet
Logga in / Bli medlem

$PHP_AUTH osv.

PHP

4 svar · 156 visningar · startad av oelbal

Medlem sedan jan. 20014 973 inlägg
Frågan#1

Försökte testa att göra en simpel inloggningsruta idag, men det verkar inte fungera. Mitt Win2K bara loopar rutan hela tiden, den verkar inte vilja acceptera värdena. Vad har jag gjort för fel?

<?
if (!isset($PHP_AUTH_USER) &#0124;&#0124; !isset($PHP_AUTH_PW))
{
  header('WWW-Authenticate: Basic realm="Private"');
  header('HTTP/1.0 401 Unauthorized');
  exit;
}
else
{
  echo("Du skrev $PHP_AUTH_USER och $PHP_AUTH_PW");
}
?>
Medlem sedan mars 2001325 inlägg
#2

I manualen kan man läsa:

The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version. In an Apache module PHP script, it is possible to use the header() function to send an "Authentication Required" message to the client browser causing it to pop up a Username/Password input window. Once the user has filled in a username and a password, the URL containing the PHP script will be called again with the variables, $PHP_AUTH_USER, $PHP_AUTH_PW and $PHP_AUTH_TYPE set to the user name, password and authentication type respectively. Only "Basic" authentication is supported at this point. See the header() function for more information.

/Marty

Medlem sedan jan. 20014 973 inlägg
#3

Misstänkte det, men tack iaf!

Medlem sedan feb. 20001 861 inlägg
#4

Har du provat att köra PHP som ISAPI-modul?

Medlem sedan jan. 20014 973 inlägg
#5

Jag kör PHP om ISAPI-modul nu...

256 ms totalt · 4 externa anrop · v20260731065814-full.14655e19
117 ms — deklarationer (db)
0 ms — hämta statistik (cache)
125 ms — hämta tråd, inlägg och bilagor (db)
128 ms — ändringar (db)