ajax2.php
===========================================
<html>
<script>
function hello(str)
{
//alert("HELLO");
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function ()
{
if(xmlhttp.readyState == 4 && xmlhttp.status==200)
{
document.getElementById("msg").innerHTML = xmlhttp.responseText ;
}
}
xmlhttp.open("GET","2.php?id="+str,true);
xmlhttp.send();
}
</script>
<input type="text" name="name" onBlur="hello(this.value)">
<span id="msg"></span>
</html>
====================================
2.php
===============================
<?php
$name=$_GET['id'];
mysql_connect("localhost","root","");
mysql_select_db("demo");
$qu=mysql_query("select * from registration_form where user_name='$name'");
$n=mysql_num_rows($qu);
if($n==1)
{
echo "USER NAME NOT VALID";
}
else
{
echo "valid user name";
}
?>
===========================================
<html>
<script>
function hello(str)
{
//alert("HELLO");
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function ()
{
if(xmlhttp.readyState == 4 && xmlhttp.status==200)
{
document.getElementById("msg").innerHTML = xmlhttp.responseText ;
}
}
xmlhttp.open("GET","2.php?id="+str,true);
xmlhttp.send();
}
</script>
<input type="text" name="name" onBlur="hello(this.value)">
<span id="msg"></span>
</html>
====================================
2.php
===============================
<?php
$name=$_GET['id'];
mysql_connect("localhost","root","");
mysql_select_db("demo");
$qu=mysql_query("select * from registration_form where user_name='$name'");
$n=mysql_num_rows($qu);
if($n==1)
{
echo "USER NAME NOT VALID";
}
else
{
echo "valid user name";
}
?>
No comments:
Post a Comment