Advertisement
Guest User

login.php

a guest
Aug 30th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include('dbconn.php');
  4. $error_msg = "";
  5. $sumbit = filter_input(INPUT_POST, 'submit');
  6. if (isset($sumbit)) {
  7. $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_ENCODED);
  8. $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_ENCODED);
  9.  
  10.  
  11. if ($username != "" || $password != "") {
  12.  
  13. $result = $db->query("SELECT * FROM `acl_admin_login` WHERE `admin_login_username`='" . quotemeta(filter_input(INPUT_REQUEST, 'username',FILTER_SANITIZE_ENCODED )) . "'");
  14. if ($result->num_rows > 0) {
  15. $row = $result->fetch_assoc();
  16. if ((strcmp($row['admin_login_password'], md5($_REQUEST['password']))) === 0) {
  17. if ($row['admin_login_status'] == 1) {
  18. $_SESSION['name'] = $row['admin_login_username'];
  19. header("Location:admin.php");
  20. } else {
  21. $error_msg = "Your not allowed to access";
  22. }
  23. } else {
  24. $error_msg = "Username or Password are wrong";
  25. }
  26. } else {
  27. $error_msg = "Username or Password are wrong";
  28. }
  29. } else {
  30. $error_msg = "Please enter your username or password";
  31. }
  32. }
  33. ?>
  34. <!DOCTYPE html>
  35. <html>
  36. <head>
  37. <title>tutorial</title>
  38. <link rel="shortcut icon" href="images/logo.png" />
  39. <meta charset="UTF-8">
  40. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  41. <link rel="stylesheet" href="css/bootstrap.min.css">
  42. <link href='https://fonts.googleapis.com/css?family=Asset|Diplomata+SC|Montserrat|Merriweather:400,900,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
  43. <link rel="stylesheet" href="css/style.css">
  44. </head>
  45. <body>
  46. <div class="">
  47. <form class="form-signin col-lg-offset-3 col-lg-6" id="login-form" action="login.php"
  48. method="POST">
  49. <h2 class="form-signin-heading">Login</h2>
  50. <label class="sr-only" for="inputUsername">Username</label>
  51. <input type="text" autofocus="" name="username" required="" oninvalid="this.setCustomValidity('please enter your username')" placeholder="username" class="form-control" id="inputUsername">
  52. <label class="sr-only" for="inputPassword">Password</label>
  53. <input type="password" oninvalid="this.setCustomValidity('Please enter your password')" required="" name="password" placeholder="Password" class="form-control" id="inputPassword">
  54. <br>
  55. <button type="submit" class="btn btn-lg btn-primary btn-block submit" name="submit" >Sign in</button>
  56. <?php
  57. if ($error_msg != null || $error_msg != '') {
  58. echo "<br><p style=\"color:red;\font-size:20px;\">" . $error_msg . "</p>";
  59. }
  60. ?>
  61. </form>
  62. </div>
  63.  
  64. <script src="js/jquery-2.2.0.min.js"></script>
  65. <script src="js/bootstrap.min.js"></script>
  66. <script src="js/main.js"></script>
  67. </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement