I would have thought the following modification would enable me to connect this script to a database of different members, but it gives me the error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/.sites/110/site133/web/indexer.php on line 6
How can I modify this script to authenticate from a database?
<?php
$link = mysql_connect("••••••","••••••","••••••") or die("Could not connect: ".mysql_error());
mysql_select_db("ositoweb")or die("Could not select database: ".mysql_error());
$query = "SELECT id,uname, pword FROM ithf_members WHERE uname = '$SERVER['PHP_AUTH_USER']' and pword = '$SERVER['PHP_AUTH_PW']'";
$result = mysql_query($query) or die("Could not perform query: ".mysql_error());
$row = mysql_fetch_array($result);
$uname = $row['uname'];
$pword = $row['pword'];
if (!isset($SERVER['PHP_AUTH_USER'], $SERVER['PHP_AUTH_PW'])
|| !($SERVER['PHP_AUTH_USER'] == $uname && $SERVER['PHP_AUTH_PW'] == $pword))
{
header('WWW-Authenticate: Basic realm="Authorization Required!"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required!';
exit;
}
else
{
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>test</title>
</head>
<body>
<p>You must have entered the right password.</p>
<a href="indexem.php">Click here to test multi page authentication.</a>
</body>
</html>
<?php
}
?>