$checkemail = mysql_query("SELECT * FROM users WHERE email = '".$email."'");
Never, never, ever do it. This is asking for problems : SQL injection, random errors (the only quote is valid in email addresses, BTW).
There are parameterized queries , use them. These are just a few lines of code, but this is the difference between a lack of security, like a barn door, and secure interaction with the database.
if(mysql_num_rows($checkemail) == 1) { $valid = 'false'; } else { $valid = 'true'; }
- a very verbose way to say
$valid = mysql_num_rows($checkemail) == 1;
According to the docs, the remote verification response is logical rather than JSON-encoded JSON.
You have "true" or "false" which will become "\"true\"" or "\"false\"" via json_encode() , which is not true. Actual true or false will become "true" or "false" , which is true.
Setting the content type of the response to JSON may also be a good idea:
header('Content-type: application/json');
source share