I'm using the jQuery validator's remote method to determine if an email address already exists in our SaaS platform.
The code below is what we are using and it's fine. However, we would like to ideally return some information about the existing user, so that we may display a link to the existing patient's profile.
I've scoured the validator docs and can't seem to find any way to handle return parameters other than true/false. Is this a limitation of the remote method?
jQuery
form.validate({
rules: {
email: {
remote: {
url: "CheckEmailExists.php",
type: "post"
}
}
},
messages: {
email: {
remote: "This email address is already assigned to an existing patient"
}
},
});
PHP
$existingUserQuery = "SELECT tbl_patients.patient_id FROM tbl_patients WHERE tbl_patients.patient_email = :email";
$getUser = $pdo->prepare($existingUserQuery);
$getUser->bindparam(":email", $email);
$getUser->execute();
$numCount = $getUser->rowCount();
if ($numCount > 0) {
echo 'false';
} else {
echo 'true';
}