Authentication Fails

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Oct 04, 2005 1:29 am    Post subject: Authentication Fails Reply with quote

Ok , I know im pretty good at coding but this is rediculous. I tried adding the
same type of Password Protection to my script as Abyss Web Server's and all
that happens is for me to enter my Username and Password again. :/

Can someone please tell me whats wrong ?

Edit: This problem is now solved. Thanks anyway :-)

Sincerely , TRUSTpunk


Last edited by TRUSTAbyss on Tue Oct 04, 2005 9:24 pm; edited 1 time in total
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Oct 04, 2005 9:12 am    Post subject: Reply with quote

Tbh I'd just make a database of accounts and use your own login form.
This is about of equal length. (Off the top of my head, though. (Y helo thar errors.))
Code:

function loggedin() {
  if (@mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `name` = '".addslashes($_COOKIE['name'])."' AND `password` = '".md5(addslashes($_COOKIE['password']))."'")) > 0)
    return true;
  else return false;
}

_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Tue Oct 04, 2005 9:22 am    Post subject: Re: Authentication Fails Reply with quote

The code looks fine to me

apart from this line
Code:
$pass = $_SERVER['PHP_AUTH_PASS'];


The server var for the password is actually $PHP_AUTH_PW
so that line should read

Code:
$pass = $_SERVER['PHP_AUTH_PW'];


hope that helps
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Tue Oct 04, 2005 9:23 am    Post subject: Reply with quote

Off the top of my head, why do you appear to be using NTLM authorisation when Abyss/standard is 'Basic Auth'?

Check out this topic for a working example of what you *should* be doing :)

http://www.aprelium.com/forum/viewtopic.php?t=965

Hope this helps...
_________________

"Invent an idiot proof webserver and they'll invent a better idiot..."
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Tue Oct 04, 2005 8:09 pm    Post subject: Reply with quote

I would have searched if I knew what I was searching for but that link really
did help me out alot , my code is a little different and it works great. LateR!

PHP Authentication

Code:

<?php
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];

$realm = "You need to login lol";

if ((!isset($user)) && (!isset($pass))) {
 header("WWW-Authenticate: Basic realm=\"$realm\"");
 header("HTTP/1.1 401 Unauthorized");

 include("includes/error401.php");
 exit;
}
elseif (($user != "foo") || ($pass != "bar")) {
 header("WWW-Authenticate: Basic realm=\"$realm\"");
 header("HTTP/1.1 401 Unauthorized");

 include("includes/error401.php");
 exit;
}
?>
Send File or Send Message!


Thank you Roganty for warning me about that variable.

Sincerely , TRUSTpunk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group