Guest User

Untitled

a guest
Feb 24th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 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. setcookie("login", "$username", time()+60*60*24*7); //<- 1 week!
  13. //if yes redirect to index.php
  14. header('Location: index.php');
  15. }
  16. else {
  17. //if no -> $error tonen
  18. $error = true;
  19. }
  20.  
  21. // remember login (cookie)
  22. // if yes -> redirect to index.php
  23. // if no -> $error tonen
  24. }
  25.  
  26.  
  27. ?><!DOCTYPE html>
  28. <html lang="en">
  29. <head>
  30. <meta charset="UTF-8">
  31. <title>IMDFlix</title>
  32. <link rel="stylesheet" href="css/style.css">
  33. </head>
  34. <body>
  35. <div class="netflixLogin">
  36. <div class="form form--login">
  37. <form action="" method="post">
  38. <h2 form__title>Sign In</h2>
  39.  
  40. <?php if( isset($error) ): ?>
  41. <div class="form__error">
  42. <p>
  43. Sorry, we can't log you in with that email address and password. Can you try again?
  44. </p>
  45. </div>
  46. <?php endif;?>
  47.  
  48. <div class="form__field">
  49. <label for="email">Email</label>
  50. <input type="text" id="email" name="email">
  51. </div>
  52. <div class="form__field">
  53. <label for="password">Password</label>
  54. <input type="password" id="password" name="password">
  55. </div>
  56.  
  57. <div class="form__field">
  58. <input type="submit" value="Sign in" class="btn btn--primary">
  59. <input type="checkbox" id="rememberMe"><label for="rememberMe" class="label__inline">Remember me</label>
  60. </div>
  61. </form>
  62. </div>
  63. </div>
  64. </body>
  65. </html>
Add Comment
Please, Sign In to add comment