Results 1 to 11 of 11

Thread: HTTP authentication just doesn't work.

Threaded View

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    HTTP authentication just doesn't work.

    when I put a authentication script, a dialog box pops up and keeps asking for name/pw, ANYTHING I put (correct or wrong) it keeps asking, and after 3-4 tries it says "requires authorisation", I copied the code from php.net and from other sites, still doesnt work, do I need to "enable" this from my browser or something?
    This piece of code, keeps asking me for name/pw.. even tho it doesnt even validate them.
    Code:
    <?php 
    
    	// File Name: auth01.php
    	// Check to see if $PHP_AUTH_USER already contains info
    
    	if (!isset($PHP_AUTH_USER)) {
    
    		// If empty, send header causing dialog box to appear
    		header('WWW-Authenticate: Basic realm="My Private Stuff"');
    		header('HTTP/1.0 401 Unauthorized');
    		echo 'Authorization Required.';
    		exit;
    	}
    
    		// If not empty, display values for variables
    
    	else {
    
    		echo "
    		<P>You have entered this username: $PHP_AUTH_USER<br>
    		You have entered this password: $PHP_AUTH_PW<br>
    		The authorization type is: $PHP_AUTH_TYPE</p>
    		";
    
    	}
    
    ?>
    or this:
    Code:
    <?php
    	header("WWW-Authenticate: Basic realm=\"System Information\""); 
    	header("HTTP/1.0 401 Unauthorized");
    	print $_SERVER['REMOTE_USER'];
    
    if ( (!isset($_SERVER['$PHP_AUTH_USER'])) || (!isset($_SERVER['$PHP_AUTH_PW'])) )
    {
        header('WWW-Authenticate: Basic realm="Private Area"');
        header("HTTP/1.1 401 Unauthorized");
        print "This page requires authorisation.";
    	print $_SERVER['$PHP_AUTH_USER'];
    	print $_SERVER['$PHP_AUTH_PW'];
        exit();
    }
    else
    {
        print "You're through to the secret page, was the effort worth it?";
    }
    ?>
    
    <html>
    <head>
    <title> .:Header password ****:. </title>
    </head>
    <body>
    </body>
    </html>
    Last edited by scr0p; May 4th, 2003 at 08:25 PM.
    asdf

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width