Hello,
Im working on a project and my authentication script suddently doesn't like me. It consists of 2 files. Authentication.html posting to Authentication.php Here they are.
Authentication.html
<html>
<body>
<table border=0 width=60% cellpadding=6 cellspacing=6 align=left valign=top>
<tr><td><font size=2>
Please Authenticate !!</font> </td><br><br>
</tr>
<tr>
<td>
<font size=1>
<form action=authenticate.php method=post>
First Name: <br><input type=text name=fname><br><br>
Last Name: <br><input type=text name=lname><br><br>
Password: <br><input type=password name=password><br><br>
<input type=submit value=submit size=4>
</form>
</font>
</td>
</tr>
</table>
</body>
</html>
Authentication.php
<?
$user="root";
$password="toor";
$db_name="Tim";
$table="users";
$connection = @mysql_connect("localhost"
,$user,$pa
ssword) or die(mysql_error());
$db = @mysql_select_db($db_name,
$connectio
n) or die(mysql_error());
$sql = "SELECT * FROM $table where fname='$_POST[fname]' AND lname='$_POST[lname]' AND password=password('$_POST[
password]'
)";
$result=mysql_query($sql);
$num=mysql_numrows($result
);
mysql_close();
if ($num!=0){
$_SESSION[auth]="yes";
echo "You are authorized - This is authenticate.php -- $SESSION[auth] <a href=authenticate2.php> Access Project</a>";
} else {
echo "Not Authorized - This is authenticate.php";
}
?>
The error im getting when I type in my password correctly with the first and last name fields is "Not Authorized - This is authenticate.php" I've tried putting a ! infront of the equal sign in $_SESSION[auth]!="yes"; I've tried two equal signs. Neither works. Do I have this in the right order. I was wondering if I need the session_start(); line. I have confirmed that I have the fields fname, lname, password in my mysql database called Tim. The table is called timtable. I am not using encryption for the password.
Any help greatly appreciated.
Jon
Start Free Trial