Advertisement
Guest User

PHP

a guest
Mar 2nd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2.  
  3. function canLogin($p_username, $p_password){
  4. //todo: database implementeren
  5. if($p_username=="hello@moyadesign.be" && $p_password="123"){
  6. return true;
  7. } else {
  8. return false;
  9. }
  10. }
  11.  
  12. //wordt er ingelogd?
  13. if (!empty($_POST)) {
  14. // opvragen wat binnen komt
  15. $username = $_POST ['email'];
  16. $password = $_POST ['password'];
  17. // controleren of login mag?
  18.  
  19. //if ok: naar loggedin.php
  20. if (canLogin($username, $password)){
  21. header('Location: loggedin.php');
  22. } else { //else feedback tonen
  23. $error = "Oh boy, that didn't go well.";
  24. }
  25. }
  26.  
  27. ?><!DOCTYPE html>
  28. <html lang="en">
  29. <head>
  30. <link rel="stylesheet" href="css/style.css" />
  31.  
  32. <meta charset="UTF-8">
  33. <title>Login</title>
  34. </head>
  35. <body>
  36.  
  37. <div class="box">
  38. <h1>Login</h1>
  39. <form action="" method="post">
  40.  
  41. <?php if( isset($error)): ?>
  42. <div class="feedback">
  43. Oh boy, that didn't go well.
  44. </div>
  45. <?php endif; ?>
  46.  
  47. <div class="form-group">
  48. <label for="email">Email address</label>
  49. <input name="email" id="email" type="email" />
  50. </div>
  51.  
  52. <div class="form-group">
  53. <label for="password">Password</label>
  54. <input name="password" id="password" type="password" />
  55. </div>
  56.  
  57. <div class="form-group">
  58. <button type="submit">Login</button>
  59. </div>
  60.  
  61. </form>
  62. </div>
  63.  
  64. <hr />
  65. </div>
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement