diff --git a/src/controller/LoginController.php b/src/controller/LoginController.php new file mode 100644 index 0000000000000000000000000000000000000000..fd29341bf47380ae4056d38f8e8371d92bd11f1e --- /dev/null +++ b/src/controller/LoginController.php @@ -0,0 +1,29 @@ +<?php +/** + * Created by PhpStorm. + * User: iqbal + * Date: 04/10/17 + * Time: 16:29 + */ + + session_start(); + + $userData = array( + "iqbal" => "test", + "test" => "pass" + ); + + if (isset($_GET['logout'])) { + $_SESSION['username'] = ""; + header("Location: ../view/login.html"); + exit; + } + + if (isset($_POST['username'])) { + if ($userData[$_POST['username']] === $_POST['password']) { + $_SESSION['username'] = $_POST['username']; + echo "<script> alert('Login berhasil') </script>"; + } else { + echo "<script> alert('Username atau password salah') </script>"; + } + } \ No newline at end of file diff --git a/src/controller/MainController.php b/src/controller/MainController.php index c0fa8167c4d80d68f33d6ea3e1411852efec3e28..52c83e7c90cc8ac8fa8c129308584b4a3c1d9f49 100644 --- a/src/controller/MainController.php +++ b/src/controller/MainController.php @@ -3,7 +3,8 @@ class MainController { public static function LoginHandler() { - echo "This is login handler"; + header("Location: http://dagojek.com/src/view/login.html"); + die(); } public static function DefaultHandler() { diff --git a/src/view/login.html b/src/view/login.html new file mode 100644 index 0000000000000000000000000000000000000000..724d78de82b4a11ae24f7211edeab2fb44662ac2 --- /dev/null +++ b/src/view/login.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Login Page | Dagojek</title> + <link rel="stylesheet" type="text/css" href="style.css"> +</head> + +<body id="login-body"> + +<div class="container"> + + <header id="login-header"> + <h1>Dagojek Login</h1> + </header> + + <section id="login-main"> + <div id="login-panel"> + <form name="loginForm" method="post" action="../controller/LoginController.php"> + <fieldset> + <legend>Login:</legend> + Username: <br> + <input type="text" placeholder="Username" name="username"> + <br> + Password: <br> + <input type="password" placeholder="Password" name="password"> + <br> + <input type="submit" value="Login"> + <a id="register-link" href="register.html">Don't have an account?</a> + <br> + </fieldset> + </form> + </div> + </section> + + <footer> + + </footer> + +</div> + +</body> +</html> \ No newline at end of file diff --git a/src/view/style.css b/src/view/style.css new file mode 100644 index 0000000000000000000000000000000000000000..ad7746f806be6eb88714769a2247fdeba2ba5fad --- /dev/null +++ b/src/view/style.css @@ -0,0 +1,36 @@ +#login-body, #register-body { + background-color: #333333; + color: #ffffff; +} + +#login-header, #register-header { + text-align: center; + margin-top: 50px; +} + + +#login-main, #register-main { + horiz-align: center; + width: 25%; + height: 60%; + margin: 0 auto; +} + +#register-link { + float: right; + color: #f4df42; + margin-top: 0.3em; +} + +.available { + background-color: greenyellow; +} + +.unavailable { + background-color: orangered; +} + +input { + margin-top: 5px; + margin-bottom: 5px; +} \ No newline at end of file