i know that this is possible but i am confused as to how it works. I have been looking online for how it is done and I think i am missing something in the process
I have this jQuery code so far:
$("#Contact_Info").validate({
rules: {
username: {
required: true,
minlength: 6,
remote: "check-username.php"
}
},
messages: {
username:{
remote: "This username is already taken! Try another."
}
}
});
How should i write my php page to make it talk to the jQuery code?
So far I have:
$name = mysql_real_escape_string($name);
$query = "SELECT USERNAME FROM T_MEMBER WHERE USERNAME='$name';";
$res = mysql_query($query);
if (mysql_num_rows($res) > 0) {
return false;
} else
return true;
How do I get the $name variable from the javascript? Do i have to set the “remote” to be POST?
Thanks in advance,
Ian McCullough
Your PHP page communicates back to the Javascript just through outputting the data. Depending on the plugin, you could achieve a
true/falseby echoing 1 or 0, or perhaps even the stringtrueorfalseThe manual says:
So you can change your PHP to this: