Guest User

Untitled

a guest
Nov 24th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <script>
  2. function insertrecord() {
  3. var xhttp = new XMLHttpRequest();
  4. xhttp.onreadystatechange = function() {
  5. if (this.readyState == 4 && this.status == 200) {
  6. retrieverecord();
  7. }
  8. };
  9. var userid = document.getElementById("txtuid").value;
  10. var username = document.getElementById("txtusername").value;
  11. var password = document.getElementById("txtpassword").value;
  12.  
  13. //var page = "insertdata.php?uid=jacky&name=Jacky Boy&pass=lol";
  14. var page = "insertdata.php?uid="+ userid +"&name=" + username +"&pass=" + password;
  15. xhttp.open("GET", page, true);
  16. xhttp.send();
  17. }
  18.  
  19. function retrieverecord() {
  20. var xhttp = new XMLHttpRequest();
  21. xhttp.onreadystatechange = function() {
  22. if (this.readyState == 4 && this.status == 200) {
  23. document.getElementById("demo").innerHTML = this.responseText;
  24. }
  25. };
  26. var page = "retrievedata.php";
  27. xhttp.open("GET", page, true);
  28. xhttp.send();
  29. }
  30.  
  31.  
  32.  
  33. </script>
  34. <!DOCTYPE html>
  35. <html>
  36. <body>
  37.  
  38. <input placeholder="Enter User Id" type="text" id="txtuid" value="" /><br>
  39. <input placeholder="Enter User Name" type="text" id="txtusername" value="" /><br>
  40. <input placeholder="Enter User Password" type="text" id="txtpassword" value="" /><br>
  41.  
  42. <input type="button" value="Insert Record" onclick="insertrecord()" />
  43. <input type="button" value="Show Records" onclick="retrieverecord()" />
  44.  
  45. <div id="demo"> </div>
  46. </body>
  47.  
  48. </html>
Add Comment
Please, Sign In to add comment