Guest User

Untitled

a guest
Sep 11th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. table, th, td {
  5. border: 1px solid black;
  6. }
  7. </style>
  8. </head>
  9. <body>
  10. <h2>Login Form</h2>
  11. <form action="/action_page.php">
  12. <div class="container">
  13. <label for="uname"><b>Username</b></label>
  14. <input type="text" placeholder="Enter Username" name="uname" required>
  15. <label for="psw"><b>Password</b></label>
  16. <input type="password" placeholder="Enter Password" name="psw" required>
  17. <button type="submit">Login</button>
  18. </div>
  19. <div class="container" style="background-color:#f1f1f1">
  20. <button type="button" class="cancelbtn">Cancel</button>
  21. </div>
  22. </form>
  23. <?php
  24. $servername = "localhost";
  25. $username = "username";
  26. $password = "password";
  27. $dbname = "myDB";
  28. $conn = new mysqli($servername, $username, $password, $dbname);
  29. if ($conn->connect_error) {
  30. die("Connection failed: " . $conn->connect_error);
  31. }
  32. $sql = "SELECT id, firstname, lastname FROM MyGuests";
  33. $result = $conn->query($sql);
  34. if ($result->num_rows> 0) {
  35. echo "<table><tr><th>ID</th><th>Name</th></tr>";
  36. while($row = $result->fetch_assoc()) {
  37. echo "<tr><td>" . $row["id"]. "</td><td>" . $row["firstname"]. " " . $row["lastname"]. "</td></tr>";
  38. }
  39. echo "</table>";
  40. } else {
  41. echo "0 results";
  42. }
  43. $conn->close();
  44. ?>
  45. </body>
  46. </html>
Add Comment
Please, Sign In to add comment