Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function __construct(DBConnection $dbConnection){
- $this->m_dbConnection = $dbConnection;
- }
- public function IsLoggedIn() {
- //Är sessionen satt ska man visas som inloggad
- if (isset($_SESSION[$this->sessionPosition])) {
- return TRUE;
- }
- return FALSE;
- }
- public function DoLogin($username, $password){
- //Hämtar in användarnamnet och använder det i switchsatsen, sedan kontrollerar man om lösenordet stämmer.
- //Stämmer båda variablerna startar sessionen och TRUE returneras.
- $this->m_dbConnection;
- $this->m_dbConnection->Connect();
- $sql = "SELECT userID FROM user WHERE username = ? AND password = ?";
- $stmt = $this->m_dbConnection->Prepare($sql);
- $stmt->bind_param("ss", $username, $password);
- $stmt->execute();
- if($stmt->fetch() === TRUE){
- if (isset($_SESSION[$this->sessionPosition]) == FALSE) {
- $_SESSION[$this->sessionPosition] = 1;
- }
- else {
- $_SESSION[$this->sessionPosition] += 1;
- }
- return TRUE;
- }
- //return FALSE;
- $this->m_dbConnection->Close();
- }
Add Comment
Please, Sign In to add comment