Welcome Guest ( Log In | Register)



 
Closed TopicStart new topic
> Http Authentication
moldboy
post Jan 15 2006, 02:31 AM
Post #1


Privileged Member
*********

Group: Members
Posts: 516
Joined: 29-April 05
From: Canada Eh?!?
Member No.: 6,408



I have a book called PHP and MySQL for dynamic web sites by Larry Ullman, and it's a very good book which I would recomend to anyone wanting to learn, but I followed a project in this book, not letter by letter, and it won' work.
I wrote this code to create an authentication script that will only work with one user but allow the credientals to be passed from one page to another. So here's the code
CODE

<?PHP

$aut = FALSE;
 
//Check for user variables
if ( (isset($_server['PHP_AUTH_USER']) AND isset($_server['PHP_AUTH_PW'])) ) {
 //Check for correct user and password
 $user = $_server['PHP_AUTH_USER'];
 $pw = $_server['PHP_AUTH_PW'];
 
 if ($user == "user" AND $pw == "password"){
   $aut = TRUE;
 }
}

//IF not authorized ask for authentication
if ($aut == FALSE){
 header('WWW-Authenticate: Basic realm="d-gression HTML editor"');
 header('HTTP/1.0 401 Unauthorized'); //If cancel is pressed
}
?>

and the actual page the require points to the above code
CODE
<?PHP
require('./auth.inc');
if ($aut == FALSE){
 echo "please <a href=\"index.php\">try again.</a>";
} else {
 echo "you're in!!!";
}
?>
Go to the top of the page
 
+Quote Post
moldboy
post Jan 15 2006, 04:29 PM
Post #2


Privileged Member
*********

Group: Members
Posts: 516
Joined: 29-April 05
From: Canada Eh?!?
Member No.: 6,408



Well after a nights sleep I figured it out, the part where it says $_server should be $_SERVER
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Jan 15 2006, 04:33 PM
Post #3


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,497
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



Topic closed as reported.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Http Authentication Without Using The Popup(3)
  2. Problem With $http_post_vars(3)
  3. Mysql Authentication Problems(11)
  4. Http_redirect() [resolved](5)


 



- Lo-Fi Version Time is now: 13th October 2008 - 07:18 PM