Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4. session_start();
  5. //require('auth.php');
  6. echo 'email post: '.$_POST['email'];
  7. echo 'email cookie '.$_COOKIE['email'];
  8. if (empty($_SESSION['authenticated']) && $_COOKIE['rememberMe'] === '1' && !empty($_COOKIE['email'])) {
  9. $_SESSION['authenticated'] = $_COOKIE['email'];
  10. header('Location: index.php');
  11. }
  12. require('dbconnect.php');
  13. if (isset($_GET["action"])) {
  14. $action = $_GET['action'];
  15. if ($action == 'account_created') {
  16. $newuser = true;
  17. }
  18. }
  19. if (!empty($_POST['email'])) {
  20. $email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
  21. $pass = $_POST['password'];
  22. $pwcheck = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM users WHERE email = '$email'"));
  23. $pwhash = $pwcheck['password'];
  24. $verifycheck = $pwcheck['verified'];
  25. echo '<br />email: ' . $email . '<br />pw:' . $pass . '<br />Hash: ' . $pwhash . 'verify: ' . $verifycheck;
  26. if ($verifycheck === '1') {
  27. //echo '<br />email: ' . $email . '<br />pw:' . $pass . '<br />Hash: ' . $pwhash . 'verify: ' . $verifycheck;
  28. if (password_verify($pass, $pwhash)) {
  29. $status = 'Login successful.';
  30. $_SESSION['authenticated'] = $email;
  31. if ($_POST['rememberMe'] === 'true') {
  32. setcookie('rememberMe', true, time() + 31000000);
  33. setcookie('email', $email, time() + 31000000);
  34. }
  35. header('Location: index.php');
  36. } else {
  37. $status = 'Login failed.';
  38. }
  39. } else {
  40. $status = 'Account not verified/account doesn\'t exist.';
  41. }
  42. } else {
  43. $status = 'No action.';
  44. }
  45. echo 'Status: '.$status;
  46. ?>
  47. <html>
  48. <head>
  49. <meta charset="utf-8">
  50. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  51. <title>DM Stream Login</title>
  52. <link rel="stylesheet" href="css/regform.css">
  53. </head>
  54. <body>
  55. <h1 class="register-title">Login</h1>
  56. <form action="" method="POST" class="register">
  57. <input type="email" name="email" class="register-input" placeholder="Email address">
  58. <input type="password" name="password" class="register-input" placeholder="Password">
  59. <input type="submit" name="submitted" value="Login" class="register-button">
  60. <div class="register-link">
  61. <span class="register-link-left"><input type="checkbox" name="rememberMe" value="true">Remember Login</span>
  62. <span class="register-link-right"><a href="register.php">Register</a></span>
  63. </div>
  64. <div class="clear"></div>
  65. <?php
  66. if (!empty($status)) {
  67. echo '<br />' . $status;
  68. }
  69. if (!empty($newuser)) {
  70. echo 'Account created.<br />Please check your email for verification.';
  71. }
  72. ?>
  73. </form>
  74. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement