Jump to content

Ajax In Web


ahmadkavand

Recommended Posts

HiMake ajax in web.If I type my username in textbox, If there is my name in database,echo "user name is invalid"elseecho "username is valid";please help me. please compelet my php filepleasei will send html,js,php file in below.//////////////html file/////////////////////<html><head><script type="text/javascript" src="selectcustomer.js"></script></head><body><form>username:<input type="text" onkeyup="showCustomer(this.value)"></form><div id="txtHint"><b>look at.</b></div></body></html>//////////////////////////////////////////////////////////////////////////////////////javascript file/////////////////////var xmlhttpfunction showCustomer(str){xmlhttp=GetXmlHttpObject();if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; }var url="getuser.php";url=url+"?q="+str;url=url+"&sid="+Math.random();xmlhttp.onreadystatechange=stateChanged;xmlhttp.open("GET",url,true);xmlhttp.send(null);}function stateChanged(){if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; }}function GetXmlHttpObject(){if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); }if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); }return null;}////////////////////////////////////////////////////////////////////////////////////////php file/////////////////////////<?php$q=$_GET["q"];$con = mysql_connect("localhost", "root", "");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("a1", $con);$sql="select username from a2 where firstname = $q;$result = mysql_query($sql);........mysql_close($con);?> please help me

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...