Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript Ajax
index.php
----------------
<!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
$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 22-Mar-13 20:43pm

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

  Print Answers RSS
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100