I am trying to create a login page and have it to submit to itself and then redirect based on if user is authenticated. But for some reason everytime i submit, with wrong username or password, i would like it to show the log in screen again but it just shows blank. But if i login correctly then it works.
<?php
if (!empty($_POST)){
require_once 'includes/db.php';
if($user->login($_POST["username"], $_POST["password"]))
echo "user is logged in";
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
<form action="" method="post">
<table align="center">
<tr>
<td>User name:</td>
<td>Password: </td>
</tr>
<tr>
<td><input type="text" name="username" /></td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="Login" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?>