Page 1 of 1

Authentication Issue

Posted: Tue Jun 17, 2003 11:53 am
by Cruzado_Mainfrm
i was trying this example from the php manual and it always returned the phrase: 'Text to send if user hits Cancel button', i guess this is because i'm not asking for authentication, but how do i that???

Code: Select all

<?php 
 if (!isset($_SERVER['PHP_AUTH_USER'])) { 
   header('WWW-Authenticate: Basic realm="My Realm"'); 
   header('HTTP/1.0 401 Unauthorized'); 
   echo 'Text to send if user hits Cancel button'; 
   exit; 
 } else { 
   echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; 
   echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"; 
 } 
?>

thnx in advance

Posted: Tue Jun 17, 2003 12:32 pm
by twigletmac
Which webserver are you using?

Mac

Posted: Tue Jun 17, 2003 12:33 pm
by Cruzado_Mainfrm
i'm using iis 5.1 in my computer, with the latest php and mysql 3

Posted: Tue Jun 17, 2003 12:47 pm
by twigletmac
That's the problem then, HTTP authentication with PHP only works when it is running as an Apache module:
http://php.net/features.http-auth

Mac

Posted: Tue Jun 17, 2003 12:49 pm
by Cruzado_Mainfrm
then how do i make iis to ask for authentication when browsing a certain file in a certain dir, is that possible?