Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. <?php
  2.  
  3. include '../lib/Session.php';
  4.  
  5. Session::init();
  6.  
  7. ?>
  8.  
  9. <?php include '../config/config.php'; ?>
  10. <?php include '../lib/Database.php'; ?>
  11. <?php include '../helpers/Format.php'; ?>
  12.  
  13. <?php
  14.  
  15. $db = new Database();
  16. $fm = new Format();
  17.  
  18. ?>
  19.  
  20. <!DOCTYPE html>
  21. <head>
  22. <meta charset="utf-8">
  23. <title>Login</title>
  24.     <link rel="stylesheet" type="text/css" href="css/stylelogin.css" media="screen" />
  25. </head>
  26. <body>
  27. <div class="container">
  28.     <section id="content">
  29.  
  30. <?php
  31.  
  32. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  33.     $username = $fm->validation($_POST['username']);
  34.     $password = $fm->validation(md5($_POST['password']));
  35.  
  36.     $username = mysqli_real_escape_string($db->link, $username);
  37.     $username = mysqli_real_escape_string($db->link, $password);
  38.  
  39.     $query = "SELECT * FROM tbl_user
  40.                         WHERE username = '$username' AND password= '$password'";
  41.  
  42.     $result = $db->select($query);
  43.     if ($result != false) {
  44.         $value = mysqli_fetch_array($result);
  45.         $row = mysqli_num_rows($result);
  46.         if ($row > 0) {
  47.             Session::set("login", true);
  48.             Session::set("username", $value['username']);
  49.             Session::set("userId", $value['id']);
  50.             header('Location: index.php');
  51.         } else {
  52.             echo "<span style='color:red; font_size:18px;'>No Result found</span>";
  53.         }
  54.     } else {
  55.         echo "<span style='color:red; font_size:18px;'> User name or Password did not match! </span>";
  56.     }
  57. }
  58.  
  59. ?>
  60.  
  61.         <form action="login.php" method="post">
  62.             <h1>Admin Login</h1>
  63.             <div>
  64.                 <input type="text" placeholder="Username" required="" name="username"/>
  65.             </div>
  66.             <div>
  67.                 <input type="password" placeholder="Password" required="" name="password"/>
  68.             </div>
  69.             <div>
  70.                 <input type="submit" value="Log in" />
  71.             </div>
  72.         </form><!-- form -->
  73.         <div class="button">
  74.             <a href="#">easy Learning project</a>
  75.         </div><!-- button -->
  76.     </section><!-- content -->
  77. </div><!-- container -->
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement