javascript - Check whether the email textbox value exists in database -
i want check value in text box present in database , clear box if value exists in database without refreshing whole page.
html:
<p>email<input type="text" name="email" id="email" size=18 maxlength=50 required></p>
query:
$echeck="select email register email='$email'"; $echk=mysql_query($echeck); $ecount=mysql_num_rows($echk); if($ecount!=0) { echo ("<script language='javascript'> var asign=document.getelementbyid(email); //now show null value asign.value=""; </script>"); }
if use alert refresh page.
window.alert('email id exist');
try implement this:
<script type="text/javascript"> function checkmailstatus(){ //alert("came"); var email=$("#email").val();// value in field email $.ajax({ type:'post', url:'checkmail.php',// put real file name data:{email: email}, success:function(msg){ alert(msg); // message come here. } }); } </script> <p>email<input type="text" name="email" id="email" onblur="checkmailstatus()"size=18 maxlength=50 required></p>
your php: checkmail.php
$echeck="select email register email=".$_post['email']; $echk=mysql_query($echeck); $ecount=mysql_num_rows($echk); if($ecount!=0) { echo "email exists"; }
Comments
Post a Comment