I am using the JQuery Validation plugin which is working great apart from the remote validation on a username to be unique.
The script is returning "true" or "false" which you will see from the below code. But I am not sure why it isn't displaying an error... It's worth mentioning the other errors on User are displayed.
Jquery Validation Rules:
User: {
required: true,
minlength: 6,
remote:{
url: 'scripts/userCheck.php',
type: "post"
}
}
JQuery Validation Messages:
User: {
required: "Please Enter a Username",
minlength: "Username must be more than 6 characters in Length",
remote: "User already exists"
}
userCheck.php:
<?php
/**
* Created by PhpStorm.
* User: nathanenglish5
* Date: 30/12/2015
* Time: 09:05
*/
include_once "init.php";
include_once "../resources/signup.class.php";
$signup = new signup($DB_con);
$return = "false";
$count = 0;
if (isset($_Post['User'])) {
$uid = $_Post['User'];
$sql = "SELECT COUNT(username) FROM username WHERE username = '$uid'";
$count = $signup->dataview($sql);
if($signup->dataview($sql)==0){
$return = "true";
}
}
?>
All the dataview class does is return a number.
Any help or guidence would be great!