I am modifying a web application that was built in PHP by another developer. Currently, if the user fills out a form and enters a username that is already being used, it displays the MySQL error Duplicate entry 'fred' for key 'username'
on a new page. I want to make it so that an error message is displayed on the same page, so I'm trying to check if the username entered matches another username in the table, but I cannot get it to work. Any thoughts?
$username_entry = ($_POST['username']);
$username_match = mysql_query("SELECT * FROM business WHERE username='$username_entry'");
if (($_POST['username']) == $username_match ) {
// do something
}