I have created a site with a login and register.It was working, but when I finished it something was very wrong, I can't login to the site.
I can register a new user and that is added in the mysql db but when I try to login the redirect does not work it will not goto the page index.php.
Can anyone look at this source because and see if you can find anything wrong.
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost","root","") or DIE ("Could not connect");
mysql_select_db("case") or die ("could not find db");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows !=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
header('location: index.php');
/*echo "Login successful. <a href='membersarea.php'>click her to enter members erea<a/>"; */
/*$_SESSION['username']=$dbusername; */
}
else
echo "Incorrect password";
}
else echo ("That username dows not exist");
}
else
die ("Please enter a username and password");
?>