Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. Login functie:
  2.  
  3. <?php
  4. class Login extends Main
  5. {
  6. protected $username;
  7. protected $password;
  8.  
  9. function log($formData = []) {
  10. session_start();
  11. $this->username = $formData['username'];
  12. $this->password = $formData['password'];
  13.  
  14. $connection = parent::Connect()->prepare("SELECT user_naam FROM users WHERE user_naam = :name");
  15. if( $connection->execute(
  16. [
  17. "name" => $this->username,
  18. ]
  19. )) {
  20. if($connection->fetch(PDO::FETCH_ASSOC)) {
  21. $getUser = parent::Connect()->prepare("SELECT * FROM users WHERE user_naam = :name");
  22. $getUser->execute(['name' => $this->username]);
  23. $user = $getUser->fetch(PDO::FETCH_ASSOC);
  24. if(password_verify($this->password, $user['user_wachtwoord'])) {
  25. $loginArray = [
  26. 'username' => $user['user_naam'],
  27. 'lastname' => $user['user_achternaam'],
  28. 'bday' => $user['user_geboren'],
  29. 'since' => $user['user_sinds'],
  30. 'role' => $user['user_role'],
  31. ];
  32.  
  33. $_SESSION['user'] = $loginArray;
  34.  
  35. var_dump($_SESSION);
  36.  
  37. echo '<script type="text/javascript"> window.open("https://intranet.onlinebazen.nl/index.php?page=dashboard","_self");</script>';
  38. } else {
  39. echo 'Geen Gebruikersnaam of wachtwoord gevonden!';
  40. }
  41. } else {
  42. echo 'Geen Gebruikersnaam of wachtwoord gevonden!';
  43. }
  44. } else {
  45. echo 'Geen Gebruikersnaam of wachtwoord gevonden!';
  46. }
  47. }
  48. }
  49. ?>
  50.  
  51. Header.php:
  52.  
  53. <!DOCTYPE html>
  54. <?php include_once($_GLOBAL['main_dir'].'Classes/autoloader.php'); ?>
  55. <?php session_start(); ?>
  56. <html lang="NL_nl">
  57. <head>
  58. <meta charset="utf-8">
  59. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  60. <meta name="viewport" content="width=device-width, initial-scale=1">
  61. <title>Online Bazen - Intranet</title>
  62. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  63. <link href="<?= $_GLOBAL['main_url'] ?>app.css" rel="stylesheet">
  64. </head>
  65. <body>
  66. <?php var_dump($_SESSION); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement