<?php
$auth = false; //assume user is not authenticated
if ( ( !isset( $PHP_AUTH_USER )) && (!isset($PHP_AUTH_PW))) {
//connect to the database
mysql_connect('xenon.truman.edu', 'dsp', '*****' )
or die ( 'Unable to connect to server.');
// select database
mysql_select_db( 'dsp' )
or die ('unable to select database');
//formulate the query
$sql \ "SELECT * FROM users WHERE username = '$PHP_AUTH_USER' and password = '$PHP_AUTH_PW'";
//execute the query and put results in variable $result
$result = mysql_query( $sql )
or die ( 'Unable to execute query' );
//get number of rows in $result
if ($num != 0 ) {
//a match was found - user authenticated.
$auth = true;
}
}
if ( ! $auth ) {
header('WWW-Authenticate: Basic realm="Private"' );
header('HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
} else {
header( 'Location: http://dsp.truman.edu/brothers.html' );
}
?>
I get a parse error on line 12 but i don't know what it is. I've looked at the place where i found the idea and can't figure out. Its exactly like the website. Its from the zend website too so i figure its accurate.
Please Help
EDIT: i got it to work but it doesn't seem to accept the password. All it does is keep popping the box up again and again.