This Code Is use for User name Already Exits or email id already exits
here this function call using Ajax Method
<?php
function ckhuserid($udetail){
$arr=explode("!@@@!",$udetail);
if($arr[1]=='edit'){
$val=executescalar("user","id","uname='".$arr[0]."' and id<>'".$arr[2]."' ", "","false","str");
} else {
$val=executescalar("user","id","uname='".$arr[0]."'", "","false","str");
}
if($val!=''){ // alresdy exist
echo "yes";
}
}
?>
// JavaScript Code
<script>
function ckhuserid(x,cas,id){ // x=this; cas= case=registration or edit profile , id=user id on edit time
uname=$(x).val();
str=uname;
if(cas=='edit'){
str=uname+"!@@@!edit!@@@!"+id;
}
$.ajax({
type: 'POST',
url: "admin/Ajax/functions.php?f=ckhuserid&p="+str,
data: {},
success: function(data12){
// alert(data12);
if(data12=='yes'){
alert("user name already exist"); $(x).focus(); return false ;
}
}});
return true ;
}
</script>
// calling method
<input type="text" onblur="return ckhuserid(this,0,0)" /> // add time
<input type="text" onblur="return ckhuserid(this,'edit',id)" /> // edit time
Comments
Post a Comment
If you Satisfied , Please Leave a comment