Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. lookup.html -->
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  3. <html>
  4. <head>
  5. <title>Lookup phone number</title>
  6. </head>
  7. <body>
  8. <h1>Lookup phone number</h1>
  9. <form name="input" action="lookup.php"
  10. method="get">
  11. Phone: <input type="text" name="phone" />
  12. <input type="submit" value="Submit" />
  13. </form>
  14. </body>
  15. </html>
  16.  
  17. lookup.php -->
  18.  
  19.  
  20. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  21. <html>
  22. <head>
  23. <title>Lookup phone number</title>
  24. </head>
  25. <body>
  26. <h1>Result</h1>
  27.  
  28. <?php
  29. $hostName = "localhost";
  30. $userName = "root";
  31. $password = "root";
  32. $dbName = "assignment1";
  33.  
  34. mysql_connect($hostName,$userName,$password) or die("Unable to connect to host $hostName");
  35.  
  36. mysql_select_db($dbName) or die("Unable to select database $dbName");
  37.  
  38. $result = mysql_query("SELECT * FROM directory where phone = $_GET[phone]");
  39.  
  40. echo "<table border='1'>
  41. <tr>
  42. <th>Firstname</th>
  43. <th>Lastname</th>
  44. </tr>";
  45.  
  46. while($row = mysql_fetch_array($result))
  47. {
  48. echo "<tr>";
  49. echo "<td>" . $row['lastname'] . "</td>";
  50. echo "<td>" . $row['phone'] . "</td>";
  51. echo "</tr>";
  52. }
  53. echo "</table>";
  54.  
  55. // Close the database connection
  56. mysql_close();
  57. ?>
  58.  
  59. </body>
  60. </html>
  61.  
  62.  
  63. output example -->
  64.  
  65. <path>/lookup.php?phone=9869696969
  66.  
  67. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  68. <html>
  69. <head>
  70. <title>Lookup phone number</title>
  71. </head>
  72. <body>
  73. <h1>Result</h1>
  74.  
  75.  
  76.  
  77. <table border='1'>
  78. <tr>
  79. <th>Firstname</th>
  80.  
  81. <th>Lastname</th>
  82. </tr><tr><td>Last name 1</td><td>9869696969</td></tr><tr><td>test dfgsdmgf</td><td>9869696969</td></tr></table>
  83. </body>
  84. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement