Before getting into why the script only returns the result âThat user does not exist!â I want to cross reference if I may to another of your topics:-
This code is extremely vulnerable for a number of reasons.
This can be discussed in the other topic if appropriate.
I mainly bring this up because you asked the other topic about âsafe websitesâ.
More importantly, if they are, please change that password ASAP. Iâve already edited it out of the post, but there is a good chance Google indexed it already.
Try storing the SQL statement in a variable, then echoing out that variable. There is a good chance that your SQL literally states SELECT * FROM users WHERE USERNAME='$username' as opposed to the value of the variable $username.
Additionally, it would probably be wiser to use the mysqli_* methods as opposed to the mysql_* ones. mysqli is the improved version of the PHP MySQL driver, and is recommended by PHP for use. Besides, mysql_* methods are rapidly on their way to becoming deprecated, so in the interest of not having obsolete code consider changing those methods.
Source:http://php.net/manual/en/mysqli.overview.php
I wasnât sure when it happened, I have been using mysqli since I started using PHP, but regardless @AkhilKokani should avoid using the mysql methods in favor of the mysqli ones.
The replacements mySQLi and PDO were both introduced in July 2004.
The old interface was flagged for removal (deprecated) in July 2013 and actually removed in December 2015.
The only old version of PHP that is still supported that supported the old interface is PHP 5.6 (not worth including PHP 5.5 any more as it will be officially dead in two days time).