The problem is, I'm beginner with php and have no idea what the difference between ajax and json. So if someone could clear that up first, that would be great.
Now on to the bigger problem
I found this validation script on this website:
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
I have it working succesfully EXCEPT for the username validation. It can connect to the external page using this javascript
$(document).ready(function() {
$("#reg").validationEngine({
ajaxName:{
file:"validateUser.php",
alertText:"* This user is already taken",
alertTextOk:"* This user is available",
alertTextLoad:"* Loading please wait"
}
});
});
In the validateUser.php
<?php
include 'include/dbc.php';
/* RECEIVE VALUE */
$validateValue=$_POST['validateValue'];
$validateId=$_POST['validateId'];
$validateError=$_POST['validateError'];
$rs_duplicate = mysql_query("select count(*) as total from users where user_name='$validateValue' ") or die(mysql_error());
list($total) = mysql_fetch_row($rs_duplicate);
/* RETURN VALUE */
$arrayToJs = array();
$arrayToJs[0] = $validateId;
$arrayToJs[1] = $validateError;
if ($total > 0){
$arrayToJs[2] = "true"; // RETURN TRUE
echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}'; // RETURN ARRAY WITH success
} else {
for($x=0;$x<1000000;$x++){
if($x == 990000){
$arrayToJs[2] = "false";
echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}'; // RETURN ARRAY WITH ERROR
}
}
}
?>
Any help would be much appreciated!
Thanks,
Kedora19