Jump to content


Photo

User Authentication


  • Please log in to reply
No replies to this topic

#1 0riole

0riole
  • Members
  • Pip
  • Newbie
  • 6 posts
  • LocationAustralia

Posted 06 October 2005 - 12:32 PM

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users