hanshinee Posted April 29, 2013 Share Posted April 29, 2013 <html> <head> <title>Get Customer Data</title> <?php //ClientID $sID= $_GET['clientID']; //variable to hold customer info $sInfo = ""; //database information $sDBServer = "localhost"; $sDBName = "jewelleries"; $sDBUsername = "root"; $sDBPassword = ""; //create the SQL query string $sql = "SELECT * FROM tbl_client WHERE clientID='$sID'"; //make the database connection $oLink = mysql_connect($sDBServer,$sDBUsername,$sDBPassword); @mysql_select_db($sDBName) or $sInfo = "Unable to open database"; if($sInfo == '') { if($oResult = mysql_query($sql) and mysql_num_rows($oResult) > 0) { $aValues = mysql_fetch_array($oResult,MYSQL_ASSOC); $sInfo = "<h3>Firstname:</h3>" .$aValues['firstname']."<br /> <h3>Lastname:</h3>".$aValues['lastname']."<br />". "<h3>Username:</h3>" .$aValues['realname']."<br /> <h3>Password:</h3>".$aValues['password']."<br />". $sInfo = "<h2>Member with ID $sID doesn't exist.</h2>"; } } mysql_close($oLink); ?> </head> <body> <div id="divInfoToReturn"> <?php echo $sInfo ?> </div> </body> </html> and that's my form <html> <head> <title>Giltz and Glam</title> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="styles/layout.css" type="text/css" /> <script type="text/javascript"> var url = "GetCustomerData.php?id="; // The server-side script function handleHttpResponse() { if (http.readyState == 4) { if(http.status==200) { var results=http.responseText; document.getElementById('divCustomerInfo').innerHTML = results; } } } function requestCustomerInfo() { var sId = document.getElementById("txtCustomerId").value; http.open("GET", url + escape(sId), true); http.onreadystatechange = handleHttpResponse; http.send(null); } function getHTTPObject() { var xmlhttp; if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if (!xmlhttp){ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } } return xmlhttp; } var http = getHTTPObject(); // We create the HTTP Object </script> </head> <body> <div id="wrap"> <div class="header"> <div class="logo"><a href="adminlogin_success.php"><img src="images/logo.png" alt="" title="" border="0" /></a></div> <div id="menu"> <ul> <li class="selected"><a href="members.php">Member Section</a></li> <li><a href="adminlogin_success.php">Admin Zone</a></li> <li><a href="display.php">Members data table</a></li> <li><a href="adminlogout.php">Admin Logout</a></li> </ul> </div> </div> <div class="left_content"> <table border="1"> <tr> <td>Search Member by ID: <p>Member ID: <input type="text" id="txtCustomerId" value="" /></p> <p><input type="button" value="Get Members Details" onclick="requestCustomerInfo()" /></p> <div id="divCustomerInfo"></div> </td></tr></table> <img src="images/ad19.jpg" alt="" title="" class="right"width="360" height="275"/> <div class="clear"></div> </div><!--end of left content--> <div class="clear"></div> </div><!--end of center content--> <div class="footer"> <div class="left_footer"><img src="images/footer_logo.png" alt="" title="" /><br /></div> <div class="right_footer"> </div> </div> </body> </html> when i click on the button get members detail i am getting this error Notice: Undefined index: clientID inC:\Users\hanshinee\Documents\EasyPHP-12.1\www\avi\GetCustomerData.php on line 7 could Anyone help? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 29, 2013 Share Posted April 29, 2013 You need check if any GET data has been sent to the page if (isset($_GET['clientID'])) ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.