Guest User

Untitled

a guest
Sep 17th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php include 'session.php';?>
  2. <?php
  3.  
  4.  
  5. if(isset($_POST['username'])){
  6. include 'dbh.inc.php';
  7.  
  8. $uname=$_POST['username'];
  9. $password=$_POST['password'];
  10. $secretcode=$_POST['secretcode'];
  11.  
  12. if (empty($uname) || empty($password) || empty($secretcode)) {
  13. header("Location: ../index.php?login=empty");
  14. } else {
  15. $sql="select * from loginform where User = ? AND SCode= ? limit 1";
  16. $stmt = mysqli_stmt_init($conn);
  17. if (!mysqli_stmt_prepare($stmt, $sql)) {
  18. header("Location: ../index.php?error=error");
  19. } else {
  20. mysqli_stmt_bind_param($stmt, "ss", $uname, $secretcode);
  21. if (mysqli_stmt_execute($stmt) == true) {
  22. $result = $stmt->get_result();
  23. if ($row = mysqli_fetch_assoc($result)) {
  24. $hashedpsw = password_verify($password, $row['Pass']);
  25. if ($hashedpsw == true) {
  26. $_SESSION['Admin']=$uname;
  27. // Log in
  28. header('Location: ../index.php?login=success');
  29. exit();
  30. } else {
  31. header("Location: ../index.php?login=error");
  32. exit();
  33. }
  34. } else {
  35. header("Location: ../index.php?login=error");
  36. }
  37. } else {
  38. header("Location: ../index.php?login=error");
  39. }
  40. }
  41. }
  42. } else {
  43. header("Location: ../page-not-found.php");
  44. }
  45. ?>
  46.  
  47. <?php
  48. ini_set('session.use_only_cookies', 1);
  49. session_set_cookie_params(0,'/','localhost',false,true);
  50. session_start();
  51. session_regenerate_id();
  52. ?>
  53.  
  54. password_hash("test", PASSWORD_BCRYPT, array('cost' => 12));
Add Comment
Please, Sign In to add comment