From d1bb2ab8ef9794774067de92b2c0bb5f7f023109 Mon Sep 17 00:00:00 2001
From: Iqbal <iqbalkhowarizmi@ymail.com>
Date: Thu, 5 Oct 2017 10:14:14 +0700
Subject: [PATCH] Fixed login functionality.

---
 src/app.php                        |  1 +
 src/controller/LoginController.php | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/app.php b/src/app.php
index 0bdcc30..29a67aa 100644
--- a/src/app.php
+++ b/src/app.php
@@ -18,6 +18,7 @@ class DagoJek {
             $instance = new DagoJek();
         }
 
+        include_once 'model/User.php';
         $instance->includeAllController();
 
         return $instance;
diff --git a/src/controller/LoginController.php b/src/controller/LoginController.php
index a0c19d1..0dc3c71 100644
--- a/src/controller/LoginController.php
+++ b/src/controller/LoginController.php
@@ -8,8 +8,11 @@
 
     session_start();
 
-    $dbconn = DB::getInstance();
-    $userData = User::GetAllUsernameAndPassword($dbconn);
+    include_once "Controller.php";
+    include_once "../model/User.php";
+
+    $pdo = DB::getInstance();
+    $userData = User::GetAllUsernameAndPassword($pdo);
 
     if (isset($_GET['logout'])) {
         $_SESSION['username'] = "";
@@ -20,8 +23,8 @@
     if (isset($_POST['username'])) {
         if ($userData[$_POST['username']] === $_POST['password']) {
             $_SESSION['username'] = $_POST['username'];
-            echo "<script> alert('Login berhasil') </script>";
+            echo "<script type='application/javascript'> alert('Login berhasil'); </script>";
         } else {
-            echo "<script> alert('Username atau password salah') </script>";
+            echo "<script type='application/javascript'> alert('Username atau password salah'); </script>";
         }
     }
\ No newline at end of file
-- 
GitLab