Hello everybody i am using jquery validation plugin. It's just working fine but my problem is if there is email exists a database. The form should not submitted until another valid email he choose. how to solve this problem.
The form is submitting even the email already exit in the database.
Here is form with ajax
<form id="ajax_form" action="form_action.php">
<label for="name">Name :</label>
<input name="name" type="text" required />
<label for="name">Email :</label>
<input name="email" type="email" required />
<input type="submit" value="Submit" />
</form>
<p id="validemail"></p>
$(function(){
$("#ajax_form" ).validate({
rules: {
email: {
required: true,
email: true,
remote: {
url: "check_email.php",
type: "post",
data: {
username: function() {
$("#validemail").html('This email already taken');
}
}
}
}
}
});
});
Here is my check_email.php for checking the email exits or not.
mysql_connect('localhost', 'root', '');
mysql_select_db('krk');
$query = mysql_query("SELECT ID FROM customers WHERE email = '{$email}' LIMIT 1");
if (mysql_num_rows($query)) {
return true;
}
else{
return false;
}
The form should not submitted until another valid email he choose. how to solve this problem.
The form is submitting even the email already exit in the database. The form should not submitted until another valid email he choose. how to solve this problem. The form is submitting even the email already exit in the database. The form should not submitted until another valid email he choose. how to solve this problem. The form is submitting even the email already exit in the database.
The PHP script is returning the wrong values. When the query returns rows, it needs to return
false
because that means the email is already used. Also, it should be echoing a string, not returning a value.