Authentication Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Authentication Issue

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Which webserver are you using?

Mac
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

i'm using iis 5.1 in my computer, with the latest php and mysql 3
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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?
Post Reply