0riole Posted October 6, 2005 Share Posted October 6, 2005 Hi, I'm useing the following script to force users to authenticate by including the below script, and I keep getting erors in line 9, but I don't see any, may be just lack of experence login.php <?include"vars.php";?> <?php function authenticate() { Header("WWW-Authenticate: Basic realm=\"secure login\""); echo "Authentication Failed!"; exit(); } if(!isset($PHP_AUTH_USER)) {h authenticate(); echo "Authorization Failed\n"; exit; } else { $checkLogin = "SELECT ID FROM $userTable WHERE $userField='$PHP_AUTH_USER' AND $passField='$PHP_AUTH_PW'"; $db = mysql_pconnect($dbHost, $dbUser, $dbPass); mysql_select_db($dbName, $db); $result = mysql_query($checkLogin, $db); $numrows = mysql_num_rows($result); $myrow = mysql_fetch_array($result); if ($numrows == 0) { authenticate(); } else { setcookie("UserID", $myrow["ID"]); $UserID = $myrow["ID"]; } } ?> And here is my vars.php <? $dbHost = "localhost"; $dbUser = "AdminUser"; $dbPass = "Password"; $dbName = "dbname"; $userTable = "Users"; $userField = "Username"; $passField = "Password"; ?> Thanks in advance, Chris Link to comment https://forums.phpfreaks.com/topic/2619-user-authentication/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.