from http://php.net/mysql_query :
Return values
For SELECT, SHOW, DESCRIBE, EXPLAIN, and other statements that return a result set, mysql_query () returns the resource with success or FALSE on error.
So, to start with, the if statement will never evaluate to false because you have "or die" in mysql_query (which is activated when mysql_query returns false).
But your if condition is not at all because you do not want to know if the query has completed, but if any results were returned. For this, you probably want to use mysql_num_rows.
As a small tip, since you only need to know if there is 1 matching username, add "LIMIT 1" at the end of your query. Then mysql will return as soon as it hits the first match, instead of searching the whole table for more results.
As an alternative method, you can use the COUNT () query and check the number returned in the result set.
source share