PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old January 30th, 2003, 10:16 AM
geomouchet geomouchet is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Acton, California
Posts: 2 geomouchet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Authentication with Logout

I have a successful PHP authentication scheme and I want to add a logout feature. I added some sample code from a DevArticle and it causes a repeated user/password prompted. Here's the code:

PHP Code:
<?php
$login_attemps 
0;
function 
authenticate() 
   {
   global 
$login_attemps;
   
$login_attemps += 1;
   if( 
$login_attemps )
      {
      
login_failed();
      exit;
      }
   
header('WWW-Authenticate: Basic realm="AVPPNG"');
   
header('HTTP/1.0 401 Unauthorized');
   
login_failed();
   exit;
   }
// The next two lines are the new code that cause a repeated user/pw prompt   
if ($_REQUEST['logout'] == true)
   { 
authenticate(); }
if(!isset(
$PHP_AUTH_USER) )
   { 
authenticate(); }
else 
   {
   
$q sprintf"SELECT * FROM member_registration
      WHERE email='%s' AND password='%s'"
,
      
trim($PHP_AUTH_USER), crypt(trim($PHP_AUTH_PW),"Xq"));
   
$result mysql_query($q);
   if (
mysql_num_rows($result) == 0)
      { 
      
authenticate(); 
      }
   else
      {
      
$email $PHP_AUTH_USER;
      
$user_profile mysql_fetch_array($resultMYSQL_ASSOC);
      }
   }
?>

Reply With Quote
  #2  
Old January 31st, 2003, 06:14 PM
Jeb. Jeb. is offline
"l33t? What's l33t?"
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 51 Jeb. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to Jeb.
geomouchet,

Try using the indexes $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] instead.

-Jeb.
__________________
Jeb.

AIM: JebediahMc - PM Me - E-Mail Me


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP Authentication with Logout


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway