-
-
- Jobs -
- Categories - -
diff --git a/jobs/Entity/User.php b/jobs/Entity/User.php new file mode 100644 index 0000000..cf2584b --- /dev/null +++ b/jobs/Entity/User.php @@ -0,0 +1,8 @@ +jobsTable = $jobsTable; + $this->catsTable = $catsTable; + $this->appsTable = $appsTable; + $this->usersTable = $usersTable; + $this->vars['cats'] = $this->catsTable->findAll(); + } + + public function home() { + return ['template' => 'admin.html.php', + 'title' => 'Jo\'s Jobs- Login', + 'vars' => $this->vars]; + } + + public function homeSubmit() { + if ($_POST['username'] == '' && $_POST['password'] = '') { + $user = $this->usersTable->find("username", $_POST['username']); + if (password_verify($_POST['password'], $user->password)) { + $_SESSION['loggedin'] = true; + $this->vars['response'] = 'You are now logged in'; + } + else { + unset($_SESSION['loggedin']); + $this->vars['response'] = 'Login Unsuccessful'; + + } + } + else { + $this->vars['response'] = ''; + if ($_POST['username'] == '') { + $this->vars['response'] .= "No Username was entered \n"; + } + if ($_POST['password'] == '') { + $this->vars['response'] .= "No Username was entered \n"; + } + $this->vars['response'] .= 'Login Unsuccessful'; + } + + return ['template' => 'response.html.php', + 'title' => 'Jo\'s Jobs- Login', + 'vars' => $this->vars + ]; + } +} \ No newline at end of file diff --git a/pages/admin/index.php b/pages/admin/index.php deleted file mode 100644 index c342d45..0000000 --- a/pages/admin/index.php +++ /dev/null @@ -1,92 +0,0 @@ - - - -
- -=$response?>
+=nl2br($response)?>