PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 29th, 1999, 12:49 PM
kumars
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I am trying to use HTML's basic realm authentication scheme. Unfortunately either it ends up not allowing any one to get in or it let any body to get in.

I have setup users to register themselves in a mySQL registration database. How can I check the entered password with the one in the database?

I know the code is getting ugly since I have not much experience in using PHP.
Can some one help...
Here is the code ...

Thanks

<?php
function authenticate() {
Header( "WWW-authenticate: basic realm='My Authentication System'");
Header( "HTTP/1.0 401 Unauthorized");
echo "You must enter a valid login ID and password to access this resourcen";
exit;
}
if (!isset($PHP_AUTH_USER) && !isset($PHP_AUTH_PW)&& !isset($userpasswd)){
authenticate();
}
else {
mysql_connect("localhost", "webuser", "");
$query = "SELECT passwd from clients where userid = '$PHP_AUTH_USER')";
$result = mysql_db_query("registration", $query);
if ($result){
while ($r = mysql_fetch_array($result)) {
$userpasswd = $r["passwd"];
}
if(!($userpasswd == $PHP_AUTH_PW)){
echo "Incorrect password THREE";
exit;
}
elseif(empty($result)){
echo "Incorrect password ONE";
exit;
}
echo "Welcome: $PHP_AUTH_USER<BR>";
echo "You have entered: $PHP_AUTH_PW<BR>";
}
} //end of function authenticate
?>
<body bgcolor='lightyellow'>
...

Reply With Quote
  #2  
Old August 29th, 1999, 01:02 PM
kumars
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Some more information:
I have RedHat6.0 Linux 2.2.5, PHP3 and is compiled with Apache3.3.x, mySQL.

Kumarsv
www.pricelane.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > password authentication system

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap