Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>E-Book Store</title>
  7.  
  8. <link rel="stylesheet" href="stylesheets/indexstylesheet.css" type="text/css" media="screen">
  9. <link rel="stylesheet" href="stylesheets/headerstylesheet.css" type="text/css" media="screen">
  10.  
  11. </head>
  12. <header
  13.  
  14. <div class="top_head">
  15. <div class="logo">
  16. <img src="images/logo.jpg" href="index.php" title="ebookstorelogo" alt="ebookstorelogo" />
  17. </div>
  18.  
  19. <nav>
  20.  
  21. <ul>
  22. <li class="selected"><a href="index.php">Home</a></li>
  23. <li><a href="ebooks.php">E-Books</a></li>
  24. <li><a href="register.php">Register</a></li>
  25. <li><a href="login.php">Log in</a></li>
  26. <li><a href="basket.php">Basket</a></li>
  27. </ul>
  28.  
  29. </nav>
  30.  
  31. </header>
  32.  
  33. <body>
  34.  
  35. <h1>Author Login</h1>
  36. <p><H2>Date:<?php
  37. echo date('d/m/y');
  38. ?>
  39. </h2></p>
  40.  
  41. <form action="login.php" method="post">
  42. <table align ="center" width ="30%">
  43. <tr>
  44. <td>User Name:</td><td><input type="text" name="username" placeholder="Enter User Name"></td>
  45. </tr>
  46. <tr>
  47. <td>Password:</td><td><input type="password" name="password" placeholder="Enter Password"></td>
  48. </tr>
  49. <tr>
  50. <td algin ="center"><input type="submit"></td>
  51. </tr>
  52. </table>
  53. </form>
  54. <a href=register.php><h3>New Registration</h3></a>
  55.  
  56. </body>
  57.  
  58. <?php
  59.  
  60. require 'bookstoredata/connect_DB.php';
  61.  
  62. if (mysqli_ping($connect)) {
  63. echo '<p>MySQL Server' . mysqli_get_server_info($connect)
  64. . ' on ' . mysqli_get_host_info($connect) . '</p>';
  65. }
  66.  
  67. $emptyErr = "";
  68. $username = $password = "";
  69.  
  70. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  71. if (empty($_POST["username"]) || empty($_POST["password"])) {
  72. $emptyErr = "Username and Password are required";
  73. echo "<BR>" . $emptyErr;
  74. } else {
  75. $username = test_input($_POST["username"]);
  76. $password = test_input($_POST["password"]);
  77. $sql = "Select authorID, firstname, lastname, username, password, email from "
  78. . " author where password = '" . $password
  79. . "' AND username = '" . $username . "'";
  80.  
  81. // echo $sql;
  82.  
  83. $result = mysqli_query($connect, $sql);
  84.  
  85. if (mysqli_num_rows($result) > 0) {
  86.  
  87. while ($row = mysqli_fetch_assoc($result)) {
  88. echo '<table border = "1" width = 20%>'
  89. . '<tr> <td>Author ID: </td><td>' . $row["authorID"] . '</td></tr>'
  90. . '<tr><td>First Name: </td><td>' . $row["firstname"] . '</td></tr>'
  91. . '<tr><td>Last Name: </td><td>' . $row["lastname"] . '</td></tr></table>';
  92. }
  93. } else {
  94. echo "<P><a href=index.php>Incorrect Username or Password, Try again</a></P>";
  95. }
  96. }
  97. }
  98. function test_input($data) {
  99.  
  100. $data = trim($data);
  101.  
  102. $data = stripslashes($data);
  103.  
  104. $data = htmlspecialchars($data);
  105. return $data;
  106. }
  107. ?>
  108.  
  109. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement