hi i'm new to php and i have problem with header i try to redirect to home page but when i use header nothing happend i tried it in anther page and work but i don't know why it don't work here
<?php session_start(); ?>
<?php ob_start();?>
<form action="index.php" method="POST">
<table>
<tr>
<?php //value='$username ' this funcation will not reset username?>
<td>username :</td><td><input type="text" name="user_name" value="<?php echo $username ?>" ></td>
</tr>
<tr>
<td>Passwored :</td><td> <input type="password" name="pass"></td>
</tr>
<tr>
<td><input type="submit" value="submit" name="submit"></td>
</tr>
<tr>
<td><a href="register.php">new account</a></td>
</tr>
</table>
</form>
<?php
if(!empty($_POST['submit'])){
if (isset($_POST['user_name'])&&isset($_POST['pass'])){
$username =htmlentities($_POST['user_name']);
$pass =htmlentities($_POST['pass']);
if ((3>strlen($username))||(strlen($username)>20)){
echo 'username must be long than 5 and less than 20 ';
exit();
}
if (6>$pass||$pass<20){
echo " passwored must be long than 6 and less than 20 ";
exit();
}
$con=mysql_connect('localhost','root','fuckyou1.') || die("can't acsess database");
$db = mysql_select_db("register");
$query=mysql_query("select * from login where username='$username' and pass='$pass'");
while ($result=mysql_fetch_assoc($query)){
$id=$result['ID'];
$db_username=$result['username'];
$db_pass=$result['pass'];
$session=$_SESSION['ID'];
if ($db_username==$username&&$db_pass==$pass){
echo $username;
header('location:home.php');
}else {
echo "user not found";
}
}
}
}
?>
<?php ob_flush();?>