Advertisement
Guest User

login.php

a guest
Aug 30th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include('dbconn.php');
  4. $error_msg = "";
  5. $sumbit = filter_input(INPUT_POST, 'submit');
  6. $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_ENCODED);
  7. $password = password_hash(filter_input(INPUT_POST, 'password', FILTER_SANITIZE_ENCODED), PASSWORD_DEFAULT, ['cost' => 12]);
  8. echo $password;
  9. //echo password_hash($password, PASSWORD_DEFAULT, ['cost' => 12]);
  10. //exit();
  11. if (isset($sumbit)) {
  12. if ($username != "" || $password != "") {
  13. $result = $db->query("SELECT * FROM `acl_admin_login` WHERE `admin_login_username`='" . $username . "'");
  14. if ($result->num_rows > 0){
  15. $row = $result->fetch_assoc();
  16. if(password_verify($row['admin_login_password'], $password)){
  17. echo "right";
  18. exit();
  19. }else{
  20. echo "wrong";
  21. exit();
  22. }
  23.  
  24. if ($row['admin_login_status'] == 1 && password_verify($row['admin_login_password'], password_hash($password, PASSWORD_DEFAULT, ['cost' => 12]))) {
  25. $_SESSION['name'] = $row['admin_login_username'];
  26. header("Location:admin.php");
  27. } else {
  28. $error_msg = "بياناتك تم منعها";
  29. }
  30. } else {
  31. $error_msg = "الرجاءالتأكد من البيانات المدخلة";
  32. }
  33. } else {
  34. $error_msg = "الرجاء تعبئة البيانات";
  35. }
  36. }
  37. ?>
  38. <!DOCTYPE html>
  39. <html>
  40. <head>
  41. <title>tutorial</title>
  42. <link rel="shortcut icon" href="images/logo.png" />
  43. <meta charset="UTF-8">
  44. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  45. <link rel="stylesheet" href="css/bootstrap.min.css">
  46. <link rel="stylesheet" href="css/font-awesome.min.css">
  47. <link rel="stylesheet" href="css/hover.css">
  48. <link rel="stylesheet" href="css/animate.css">
  49. <link rel="stylesheet" href="css/site.css">
  50. <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'>
  51. <link rel="stylesheet" href="css/style.css">
  52. <script type="text/javascript" src="js/jssor.slider.min.js"></script>
  53. </head>
  54. <body>
  55. <div class="">
  56. <form class="form-signin col-lg-offset-3 col-lg-6" id="login-form" action="login.php"
  57. method="POST">
  58. <h2 class="form-signin-heading">Login</h2>
  59. <label class="sr-only" for="inputUsername">Username</label>
  60. <input type="text" autofocus="" name="username" required="" oninvalid="this.setCustomValidity('الرجاء أدخل إسم المستخدم')" placeholder="username" class="form-control" id="inputUsername">
  61. <label class="sr-only" for="inputPassword">Password</label>
  62. <input type="password" oninvalid="this.setCustomValidity('الرجاء أدخل كلمة المرور')" required="" name="password" placeholder="Password" class="form-control" id="inputPassword">
  63. <br>
  64. <button type="submit" class="btn btn-lg btn-primary btn-block submit" name="submit" >Sign in</button>
  65. <?php
  66. if ($error_msg != null || $error_msg != '') {
  67. echo "<br><p style=\"color:red;\font-size:20px;\">" . $error_msg . "</p>";
  68. }
  69. ?>
  70. </form>
  71. </div>
  72.  
  73. <script src="js/jquery-2.2.0.min.js"></script>
  74. <script src="js/bootstrap.min.js"></script>
  75. <script src="js/wow.min.js"></script>
  76. <script>
  77. new WOW().init();
  78. </script>
  79. <script src="js/main.js"></script>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement