diff options
Implemented a simple login page for (admin) dashboard and skeleton of dashboard controller and view
5 files changed, 50 insertions, 0 deletions
| -rw-r--r-- | src/controllers/DashboardController.php | 8 | ||||
| -rw-r--r-- | src/controllers/DashboardLoginController.php | 24 | ||||
| -rw-r--r-- | src/index.php | 5 | ||||
| -rw-r--r-- | src/views/dashboard-login.php | 12 | ||||
| -rw-r--r-- | src/views/dashboard.php | 1 |
diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php new file mode 100644 index 0000000..84beb14 --- /dev/null +++ b/src/controllers/DashboardController.php @@ -0,0 +1,8 @@ +<?php +include_once('controllers/BaseController.php'); + +class DashboardController extends BaseController { + public static function get() { + include "views/dashboard.php"; + } +} diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php new file mode 100644 index 0000000..8c1cc67 --- /dev/null +++ b/src/controllers/DashboardLoginController.php @@ -0,0 +1,24 @@ +<?php +include_once('controllers/BaseController.php'); +include_once('controllers/DashboardController.php'); + +class DashboardLoginController extends BaseController { + private static $message; + + public static function get() { + include "views/dashboard-login.php"; + } + + public static function post() { + if ($_POST['username'] == "admin" && $_POST['password'] == "admin") { + // Probably a bad practice, but couldn't find if it is + $_SERVER['REQUEST_METHOD'] = "GET"; + // Load normal dashboard + DashboardController::invoke(); + } + else { + self::$message = "Bad credentials!"; + include "views/dashboard-login.php"; + } + } +} diff --git a/src/index.php b/src/index.php index b909deb..676cd56 100644 --- a/src/index.php +++ b/src/index.php @@ -3,6 +3,7 @@ <?php include_once("controllers/LandingController.php"); include_once("controllers/CreateOfferController.php"); +include_once("controllers/DashboardLoginController.php"); /* The landing page practically acts as our page router. * All request get redirected to here (look at the devrix-job-board.conf) @@ -20,6 +21,10 @@ switch ($request) { case "/CreateOffer/": CreateOfferController::invoke(); break; + case "/Dashboard": + case "/Dashboard/": + DashboardLoginController::invoke(); + break; default: http_response_code(404); break; diff --git a/src/views/dashboard-login.php b/src/views/dashboard-login.php new file mode 100644 index 0000000..1431b4f --- /dev/null +++ b/src/views/dashboard-login.php @@ -0,0 +1,12 @@ +<form method="post"> + <label for="username">Username: </label> + <input type="text" name="username"> + <br> + <label for="password">Password</label> + <input type="password" name="password"> + <br> + <input type="submit" value="Login"> +</form> +<?php + echo self::$message; +?> diff --git a/src/views/dashboard.php b/src/views/dashboard.php new file mode 100644 index 0000000..86c393a --- /dev/null +++ b/src/views/dashboard.php @@ -0,0 +1 @@ +<p>Dashboard works!</p> |
