ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
[PHP] Session Authentication error
by Patrick Hartnett other posts by this author
Apr 5 2002 5:38AM messages near this date
RE: [PHP] Sockets with windows / win32 - 'call to undefined function: ...' | [PHP] Returned e-mail (PHP mail function)
After logging in, i end up in a continual loop between index.php and 
checklogin.php.  Can someone give me a clue as to what is up and how to fix 
it?  If i set the checklogin to go to a page that does not check 
authentication if the user/pass combo passed, it works fine, but whe i send 
it to a page that checks to see if $PHP_AUTH_USER is set, i get the infinite 
loop, which is funny the first time, but really.... Thanks in advance.

*no, the comments aren't really there in the code (at least 99% of them ;) )
//index.php
//<?
// index.php - secure page
//   session_start();
//   if (!isset($PHP_AUTH_USER))
//      {
//           // If empty, send header causing dialog box to appear
//	   header("Location: 
http://dev.e-//dbapps.com/customscripts/checklogin.php");
//         exit;
//      }
//?> 

//<?php
//	session_start();
//	// File Name: checklogin.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="Webmail Testing Area"');
//		header('HTTP/1.0 401 Unauthorized');
//		exit;
//	   }
//	else if (isset($PHP_AUTH_USER))
//	   {
//		mysql_connect("***", "***", "***") or die ("Unable to connect to 
database.");
//		// select database on MySQL server
//		mysql_select_db("***") or die ("Unable to select database.");
//		$sql = "SELECT id FROM users WHERE username='$PHP_AUTH_USER' and 
password= PASSWORD('$PHP_AUTH_PW')";
//		$result = mysql_query($sql);
//		// Get number of rows in $result. 0 if invalid, 1 if valid.
//		$num = mysql_numrows($result);
//		if ($num != "0")
//		   {
//			// redirect to protected page
//			session_register($PHP_AUTH_USER);
//			session_register($PHP_AUTH_PW);
//			header("Location: http://dev.e-dbapps.com/index2.php");
//			exit();
//		   }
//		else
//		   {
//			$status = 0;
//			header("Location: 
http://dev.e-dbapps.com/customscripts/error.php?e=$status");
//			exit();
//   		   }
//	   }
//?> 

-Patrick Hartnett
toymaster
e-dbapps.com

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved