Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>E-Book Store</title>
- <link rel="stylesheet" href="stylesheets/indexstylesheet.css" type="text/css" media="screen">
- <link rel="stylesheet" href="stylesheets/headerstylesheet.css" type="text/css" media="screen">
- </head>
- <header
- <div class="top_head">
- <div class="logo">
- <img src="images/logo.jpg" href="index.php" title="ebookstorelogo" alt="ebookstorelogo" />
- </div>
- <nav>
- <ul>
- <li class="selected"><a href="index.php">Home</a></li>
- <li><a href="ebooks.php">E-Books</a></li>
- <li><a href="register.php">Register</a></li>
- <li><a href="login.php">Log in</a></li>
- <li><a href="basket.php">Basket</a></li>
- </ul>
- </nav>
- </header>
- <body>
- <h1>Author Login</h1>
- <p><H2>Date:<?php
- echo date('d/m/y');
- ?>
- </h2></p>
- <form action="login.php" method="post">
- <table align ="center" width ="30%">
- <tr>
- <td>User Name:</td><td><input type="text" name="username" placeholder="Enter User Name"></td>
- </tr>
- <tr>
- <td>Password:</td><td><input type="password" name="password" placeholder="Enter Password"></td>
- </tr>
- <tr>
- <td algin ="center"><input type="submit"></td>
- </tr>
- </table>
- </form>
- <a href=register.php><h3>New Registration</h3></a>
- </body>
- <?php
- require 'bookstoredata/connect_DB.php';
- if (mysqli_ping($connect)) {
- echo '<p>MySQL Server' . mysqli_get_server_info($connect)
- . ' on ' . mysqli_get_host_info($connect) . '</p>';
- }
- $emptyErr = "";
- $username = $password = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["username"]) || empty($_POST["password"])) {
- $emptyErr = "Username and Password are required";
- echo "<BR>" . $emptyErr;
- } else {
- $username = test_input($_POST["username"]);
- $password = test_input($_POST["password"]);
- $sql = "Select authorID, firstname, lastname, username, password, email from "
- . " author where password = '" . $password
- . "' AND username = '" . $username . "'";
- // echo $sql;
- $result = mysqli_query($connect, $sql);
- if (mysqli_num_rows($result) > 0) {
- while ($row = mysqli_fetch_assoc($result)) {
- echo '<table border = "1" width = 20%>'
- . '<tr> <td>Author ID: </td><td>' . $row["authorID"] . '</td></tr>'
- . '<tr><td>First Name: </td><td>' . $row["firstname"] . '</td></tr>'
- . '<tr><td>Last Name: </td><td>' . $row["lastname"] . '</td></tr></table>';
- }
- } else {
- echo "<P><a href=index.php>Incorrect Username or Password, Try again</a></P>";
- }
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement