public function checkUser($username, $password) { $count = 0; $userDAO = new UserDAO(); $lijst = $userDAO->getAll(); foreach ($lijst as $user) { if ($user->getUsername() == $username && $user->getPassword() == $password) { $count++; } } if ($count >= 1) { $_SESSION["topSecret"] = "access granted"; } else { $_SESSION["topSecret"] = "access denied"; echo "FALSE username and/or password"; } }
$sql = "SELECT gebruikersnaam, wachtwoord FROM gebruikers"; $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD); $resultSet = $dbh->query($sql); var_dump($resultSet); $lijst = array(); foreach ($resultSet as $rij) { $u = new User($rij["gebruikersnaam"], $rij["wachtwoord"]); array_push($lijst, $u); } var_dump($lijst); $dbh = null; return $lijst; } } $userDAO = new UserDAO(); $users = $userDAO->getAll(); var_dump($users); $userDOA = new UserDAO(); $newUser = $userDAO->createUser("liesenborghs", "testpwd"); var_dump($newUser); //class UserService { // // public function storeUser($username, $password) { // $userDAO = new UserDAO(); // $userDAO->createUser($username, $password); // } // // public function checkUser($username, $password) { // $count = 0; // $userDAO = new UserDAO(); // $userDAO->getAll();
$valid = false; } if ($valid == true) { if (UserDAO::checkUsernameAvailable($user->username)) { UserDAO::addUser($user); redirect_to("ManageAdmins.php"); } else { $message = "Username not available"; } } } catch (Exception $exception) { echo "{\"success\":false}"; } } require "partials/header.php"; $admins = UserDAO::getAll(); ?> <div class="table-responsive" style="padding-top:200px;margin-left:150px;width:70%; "> <h4>Manage admins</h4> <h5 style="color:red"> <?php echo $message; ?> </h5> <button class="btn btn-success btn-sm pull-right" data-target="#AddAdminModal" data-toggle="modal">Add Admin </button> <br><br/> <table class="table table-striped table-bordered"> <thead> <tr> <td>S.No.</td>
<?php require_once 'Data/UserDAO.php'; require_once 'Data/ChallengeDAO.php'; require_once 'Data/WeighpointDAO.php'; require_once 'Data/ViewerDAO.php'; require_once 'algemenefuncties.php'; require_once 'Business/UserService.php'; require_once 'Business/ChallengeService.php'; $userDAO = new UserDAO(); $userLijst = $userDAO->getAll(); $challengeDAO = new ChallengeDAO(); $challengeLijst = $challengeDAO->getAll(); $weighpointDAO = new WeighpointDAO(); $weighpointLijst = $weighpointDAO->getAll(); $viewerDAO = new ViewerDAO(); $viewerLijst = $viewerDAO->getAll(); ?> <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title></title> </head>
<?php include_once 'Data/userDAO.php'; ?> <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php $userDAO = new UserDAO(); $userlijst = $userDAO->getAll(); var_dump($userlijst); ?> </body> </html>