I read through ur codes and i realized that u have sth wrong with ur syntax
this is wrong:
PHP Code:
$query = "SELECT * FROM $login_table WHERE Username = '$username'";
and this is right:
PHP Code:
$query="SELECT * FROM $login_table WHERE username = '".$username."' ";
That`s why ur script doesnt work
And after that i suggest u should recheck the username using "mysql_num_rows" to make sure its is a legal username