I am building a php page that registers a user on my site. Part of it has a button to check to see if the username has been taken or not by opening a popup window and putting the entered username in the url and php queries the database like this:
<?php
include("connDB.php");
$chk = $_GET['chk'];
$sql="select UserName from reg where UserName=$chk";
$result=mysql_query($sql,$conn);
if($chk==NULL || $chk=="") {
echo $chk." no username entered";
}elseif(!$result) {
echo $chk." Username already in Use";
}else{
echo $chk." is available";
}
?>
this page is opened in the popup window. The problem is that even if i type a username that is not in the database it is still coming back as user not available, ie meaning that it is in the database.
the database is actually empty???