I have a basic register form, and I run a query for the submitted name. It works when a value is found and it echo's out " that name is already taken" ....
But when the query does not find the name...and I believe i'm getting a NULL back out of the query, my if/else statement is not executing....
I'm new and I'm sure my code is a little bloated...but can you guys tell my why the (2nd)if statement is true...is not echoing out the statement....
Code: Select all
function check_if_exists($req_username)
{
if($_POST['username'] !== "" and $_POST['username'] !== NULL)
{
$query = mysql_query("SELECT * FROM login WHERE user_name = '$req_username'");
while($row = mysql_fetch_array($query))
{
if($row['user_name']== NULL or $row['user_name'] == "")
{
echo "thAT NAME IS AVAILABLE";
}
else
{
echo " that name is already taken";
}
}
}
else
{
echo "Fields cannot be blank";
}
}