Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lookup.html -->
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
- <html>
- <head>
- <title>Lookup phone number</title>
- </head>
- <body>
- <h1>Lookup phone number</h1>
- <form name="input" action="lookup.php"
- method="get">
- Phone: <input type="text" name="phone" />
- <input type="submit" value="Submit" />
- </form>
- </body>
- </html>
- lookup.php -->
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
- <html>
- <head>
- <title>Lookup phone number</title>
- </head>
- <body>
- <h1>Result</h1>
- <?php
- $hostName = "localhost";
- $userName = "root";
- $password = "root";
- $dbName = "assignment1";
- mysql_connect($hostName,$userName,$password) or die("Unable to connect to host $hostName");
- mysql_select_db($dbName) or die("Unable to select database $dbName");
- $result = mysql_query("SELECT * FROM directory where phone = $_GET[phone]");
- echo "<table border='1'>
- <tr>
- <th>Firstname</th>
- <th>Lastname</th>
- </tr>";
- while($row = mysql_fetch_array($result))
- {
- echo "<tr>";
- echo "<td>" . $row['lastname'] . "</td>";
- echo "<td>" . $row['phone'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- // Close the database connection
- mysql_close();
- ?>
- </body>
- </html>
- output example -->
- <path>/lookup.php?phone=9869696969
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
- <html>
- <head>
- <title>Lookup phone number</title>
- </head>
- <body>
- <h1>Result</h1>
- <table border='1'>
- <tr>
- <th>Firstname</th>
- <th>Lastname</th>
- </tr><tr><td>Last name 1</td><td>9869696969</td></tr><tr><td>test dfgsdmgf</td><td>9869696969</td></tr></table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement