Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
index.php
----------------
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<title>Example Ajax GET</title>

<script type="text/javascript"><!--

 function showUser()
{
    var str = document.getElementById('pid').value;
    //alert(str);
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
     //alert("testttt");
     document.getElementById("test").innerHTML = xmlhttp.responseText;
     //alert(str);
    }
  }
xmlhttp.open("GET","test1.php?q="+str,true);
xmlhttp.send();

}

</script>
</head>
<body>

<form action="#" method="post">
Enter Text:<input type="text" id="pid"/>
<input type="submit"  value="save" onclick="showUser();"/>
</form>
<div id="test"></div>
</body>
</html>


test1.php
-------------------
PHP
<?php
$con =mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("ebaynew",$con) or die(mysql_error());
$id = $_GET['q'];
$query ="select * from productdetails where ebayId = $id";
$res = mysql_query($query) or die(mysql_error());
$no = mysql_num_rows($res);
if($no > 0)
{
    //$msg = "Product Already Exist";
    echo "Product Already Exist";
}
?>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900