I have a registration form which is using jQuery validator as:
$('reg_form').validate({
ignore:"",
rules : {
user_name : {
required :1,
minlength :8,
remote :"check_user_name.php"
},
password : {
required :1,
minlength :8,
},
firstname : {
required :1,
},
lastname : {
required :1,
},
email : {
required :1,
},
}
});
It worked pretty well but the problem is remote. It never detects if the username is already in the DB.
The code in remote is as:
$uname = $_GET["user_name"];
$UserObj = new User();
echo $UserObj->checkUniqueUser($uname);
checkUniqueUser() will check if there is an user with the same name it will return false else true.
I got the URL from the request watch
http://project.localhost/check_user_name.php?user_name=admin
I hot linked the URL and it says false, since the admin is already there in the DB and if I change to something else it shows true (of course its not there in DB)
Can someone please help me on this ? Hope I was able to make it clear what I have done so far and what issue I am facing.
This is my function which I have in the User class.
public function checkUniqueUser($username){
$return = true ;
global $db ;
$db->query("select iduser from user where
user_name = '".$this->cleanInput($username)."'");
if($db->numRows() > 0 ){
$return = false ;
}
return $return ;
}