Hey im trying to create a simple login sysytem but the 'else' part of the if then else statement isnt firing and i cannot work out why. Im pretty sure the curly brackets are correct. Thanks
My code is listed below....
<html>
<body>
<?php
mysql_connect("localhost", "root", "dinosaur") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("info") or die(mysql_error());
$username = $POST['username'];
$password = $POST['password'];
$result = mysql_query("SELECT * FROM users WHERE username = '$username' && password='$password'");
while($row = mysql_fetch_array($result))
{
if(($row['username'] == $username) && ($row['password'] == $password))
{
echo $row['password'].' you are logged in';
session_start();
session_register('username');
}
else
{
echo "you are not logged in";
print "<script>";
print " self.location='reg.html'";
print "</script>";
}
}
?>
</body>
</html>