I want to check whether the username and email is already exist in edit page.. So need to check it except for that particular if.. How is it possible using jquery validator..
I have tried with following format :
Jquery :
<script>
$(document).ready(function(){
$("#frmForm").validate({
rules: {
empemail: {
required: true,
remote: "../admin/checkEmail.php?data=email"
},
username: {
required: true,
remote: "../admin/checkEmail.php?data=name"
},
},
messages: {
username: {
required:"*",
remote: "already exists"
},
empemail: {
required:"*",
remote: "already exists"
},
}
});
});
</script>
HTML page
<form method="post" action="updateEmp.php" id="frmForm">
<label >Email </label>
<input type="email" name="empemail" value="<?php echo $row['email'] ?>">
<label >Username</label>
<input type="text" name="username" value="<?php echo $row['username'] ?>">
<button class="btn btn-primary btn-sm" type="submit" >Update</button>
</form>
Pass that particular id in your remote url like remote: "../admin/checkEmail.php?data=email&id=23"
say your particular id be 23
and in your checkEmail.php you can write query like
"SELECT email FROM table_name WHERE email='".$_GET['email']."' AND id!='".$_GET['id']."'"
same way you can do for username also