Jump to content


This topic is now archived and is closed to further replies.


User Authentication

Recommended Posts



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 :(




 function authenticate() {
  Header("WWW-Authenticate: Basic realm=\"secure login\"");
  echo "Authentication Failed!";
 if(!isset($PHP_AUTH_USER)) {h
   echo "Authorization Failed\n";
 } else {
   $checkLogin = "SELECT ID FROM $userTable WHERE
$userField='$PHP_AUTH_USER' AND
   $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) {
   } 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,




Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.