simple authentication code doesn't work
Posted: Wed Jan 31, 2007 5:18 pm
I'm trying to use code i found for simple validation, it consists of 3 itty bitty scripts
the first is vars.php
the second is login.php
and the third is index.php
the error i get when i try to go to login.php is
Parse error: parse error in c:\program files\easyphp1-8\www\portal\login.php on line 9
and i have no idea at all how to fix it
the first is vars.php
Code: Select all
<?
$dbHost = "127.0.0.1";
$dbUser = "root";
$dbPass = "root";
$dbName = "portal";
$userTable = "Users";
$userField = "Username";
$passField = "Password";
?>Code: Select all
<?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"];
}
}
?>Code: Select all
<?include"login.php";?>
<html>
<center>Hello there Welcome</center>
</html>Parse error: parse error in c:\program files\easyphp1-8\www\portal\login.php on line 9
and i have no idea at all how to fix it