Advertisement
Guest User

Untitled

a guest
Feb 27th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?php
  2. include_once ('functions.inc.php');
  3.  
  4. if ( !empty($_POST)) {
  5. //get username and password from $_POST
  6. $username = $_POST['email'];
  7. $password = $_POST['password'];
  8.  
  9. // check if a user can login (function)
  10. if (canILogin($username, $password) == true) {
  11. //remember login (cookie)
  12.  
  13. session_start();
  14. $_SESSION['username'] = $username;
  15. $_SESSION['loggedin'] = true;
  16.  
  17.  
  18. /* $salt = "21313abrea34567";
  19. $cookieVal = $username . "," . md5($username.$salt);
  20. setcookie("login", "$cookieVal", time()+60*60*24*7); //<- 1 week!*/
  21.  
  22. //if yes redirect to index.php
  23. header('Location: index.php');
  24. }
  25. else {
  26. //if no -> $error tonen
  27. $error = true;
  28. }
  29.  
  30. // remember login (cookie)
  31. // if yes -> redirect to index.php
  32. // if no -> $error tonen
  33. }
  34.  
  35.  
  36. ?><!DOCTYPE html>
  37. <html lang="en">
  38. <head>
  39. <meta charset="UTF-8">
  40. <title>IMDFlix</title>
  41. <link rel="stylesheet" href="css/style.css">
  42. </head>
  43. <body>
  44. <div class="netflixLogin">
  45. <div class="form form--login">
  46. <form action="" method="post">
  47. <h2 form__title>Sign In</h2>
  48.  
  49.  
  50.  
  51. <?php if(isset($error)):?>
  52. <div class="form__error">
  53. <p>
  54. Sorry, we can't log you in with that email address and password. Can you try again?
  55. </p>
  56. </div>
  57. <?php endif; ?>
  58.  
  59.  
  60.  
  61. <div class="form__field">
  62. <label for="email"l">Email</label>
  63. <input type="text" id="email" name="email">
  64. </div>
  65. <div class="form__field">
  66. <label for="Password">Password</label>
  67. <input type="password" id="password" name="password">
  68. </div>
  69.  
  70. <div class="form__field">
  71. <input type="submit" value="Sign in" class="btn btn--primary">
  72. <!--type moet submit zijn om te verzenden-->
  73. <input type="checkbox" id="rememberMe"><label for="rememberMe" class="label__inline">Remember me</label>
  74. </div>
  75. </form>
  76. </div>
  77. </div>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement