Hello all,
I seem to be on this board a lot lately and that's because I've gotten some good pointers/tips/answers from a number of you, and for that I am appreciative 🙂
Moving on, I seem to be a bit confused as to what I'm doing wrong here, if anything. Let me give you a brief layout. I have two directories:
/bills/ &
/bills/inc/ for include files
In /bills/inc/ I have a file called functions.inc.php which contains all my home brewed functions. And another file called config.inc.php, which contains stuff like $dbhost = localhost, $dbpass = bleh, etc.
in /bills/ i have a number of files that I want to start off the same way, but I can't even seem to get 1 to work properly.
I first start off start by checking to see if $PHP_AUTH_USER && $PHP_AUTH_PW have been set yet, if not, then I call auth() from my functions file. It pops up the http-auth header, and I login. The next step is to verify the auth() information against a database. I have this verification in my functions.inc.php as well, and it looks like this:
function userConnect($dbhost, $dbuname, $dbpass, $dbname, $user_result_num) {
global $connection, $db, $user_check, $user_result, $user_result_num;
$connection = mysql_connect($dbhost, $dbuname, $dbpass)
or die("Could Not Establish A Connection To MySQL.");
$db = mysql_select_db($dbname, $connection)
or die("Could Not Select Database: <b>$dbname</b>");
$user_check = "SELECT * FROM users
WHERE username='$PHP_AUTH_USER'
AND passwd=Password('$PHP_AUTH_PW')
AND uid <= '2'";
$user_result = mysql_query($user_check)
or die("Fields Did Not Match Those In Database. (Wrong Username and/or Pass
word?!)");
$user_result_num = mysql_num_rows($user_result);
// or die("Could Not Verify Row Results.");
if (!$user_result_num) {
echo "<b>Not Authorized!!!</b> Close browser and try again.";
}
}
However, no matter what username/passwd I put in the http-auth, it just outputs the HTML page regardless of whether or not the u:/p: is correct. I've tried changing some things around in both the index.php file & in the functions.inc.php file, but w/ no success. It either seems to not work, or just do as it pleases.
I'm working on this as a side project for my own use (and possibly public use, if I get it working =/ ) so it's in development right now and you can see what I'm talking about at:
http://thematrix.cl.msu.edu/bills/index.php(s)
http://thematrix.cl.msu.edu/bills/inc/function.inc.phps
thank you for any pointers, and I'll be glad to help clarify things if necessary. take care.
./brm