I have a problem with using jQuery validate remote function with php. I try to check the user id with query whether the user id is exist or not. But it alway show user is in used.
Here is my jQuery validate code:
userID: {
required: true,
minlength: 5,
remote : {
url: "checkUserId.php",
type: "post"
}
},
Here is my php checking code:
<?php
include "session.php";
include 'dbConnect.php';
global $conn;
$requestedID = $_POST['userID'];
$query = "SELECT * FROM Users WHERE _userID = '$requestedID'";
$result = sqlsrv_query($conn,$query);
$row_count = sqlsrv_num_rows($result);
if($row_count === false){
echo 'false';
}
else if($row_count >=0){
echo 'true';
}
?>
Anything I did wrong in my query?
$_POSTto ensure that the correct value is being passed through by jQuery?_userIDoruserid? Also passing user provided data directly to the sql opens you to injections.