Hi all I am using a php script to allow me to login to an admin area and the password is stored in a mysql database
can anyone please assist me with this as I am receiving an error::
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING
in /home/user/public_html/adm
inonly/ind
ex.php on line 49 THIS LINE:-
AND Password = PASSWORD('".$pass"')");
Here is the full script including html ... please not this is using a session and that is declared at the start of the page. I wanto actually arrive at a form if the user is not logged in and then be bale to input the username and password to able me to login.
Many thanks for the help....
BY the way this page is being posted back to itself "index.php"
********THE HTML AND SCRIPT********************
**********
**********
*********
<? session_start(); ?>
<html>
<head>
<title>Administration only</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<? require ("/home/user/public_html/h
iddenscrip
ts/myVaria
bles.php")
;
$pagelinks = "<A HREF = 'modrides.php'>Modify the rides</a><br><br>";
$pagelinks .= "<A HREF = 'newride.php'>Add a new ride</a><br><br>";
$pagelinks .= "<A HREF = 'logout.php'>Log out</a><br><br>";
if($username && $pass){
if ($username == $admin){
echo $username.", you are already logged in.<br>";
echo $pagelinks;
exit;
}
//Connect and select database
$connect or die ("Could not connect to the database, please check your script variables!");
$use_db or die ("Unable to connect to the database");
//Fetch all items from login table and look for a positive match for uservame and password and store in result
$result = mysql_query("SELECT * FROM login where loginname = '".$username"'
AND Password = PASSWORD('".$pass"')");
//If result does not match the display message and exit script
if(!$result){
echo "<h2>WHOOPS It looks as though your username or password is wrong</h2><br>";
exit;
}
//If result returns more than 1 row set test $admin to same as $username, in other words a positive match means
//that the password is correct and i can set my test condition above to allow entry to admin area
if(mysql_num_rows($result)
> 0){
$admin = $username;
session_register("admin");
//Register the session variable to post back to this script
//Session already started at top of page
echo "<h3>Welcome $username it is nice to see you again<br><br>";
echo $links;
exit;
}
// on invalid login, show user HTML form to login again
else {
echo "Invalid login. Please try again.<BR><BR>";
}
}
?>
<form name="letmein" method="post" action="index.php">
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> <td colspan="5"><h5><font face="Arial, Helvetica, sans-serif">Username:</fon
t></h5></t
d>
<td colspan="2"><input name="username" type="text" id="username"></td>
</tr>
<tr><td colspan="5"></td><td height="5" colspan="2"></td></tr>
<tr> <br><td colspan="5"><h5><font face="Arial, Helvetica, sans-serif">Password</font
></h5></td
>
<td width="164"><input name="pass" type="password" id="password"></td>
<td width="491"><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>