From da4ad0b6fb5a21c2d49a19faf0a2cb1f7aee349f Mon Sep 17 00:00:00 2001
From: aldrichvalentino <aldrich.vh97@gmail.com>
Date: Wed, 4 Oct 2017 12:54:35 +0700
Subject: [PATCH] transaction insertion fixed

---
 controller/orderController.php | 5 +++--
 model/order.php                | 5 ++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/controller/orderController.php b/controller/orderController.php
index 0314e750..fdc22714 100644
--- a/controller/orderController.php
+++ b/controller/orderController.php
@@ -54,6 +54,7 @@ if(isset($_GET['driverId'])){
 
 if(isset($_POST['pickup'])){
     $date = date('Y-m-d H:i:s');
+    //echo $date;
     $pickup = $_POST['pickup'];
     $destination = $_POST['destination'];
     $driverId = $_POST['driverId'];
@@ -63,6 +64,6 @@ if(isset($_POST['pickup'])){
     $comment = $_POST['comment'];
     $transaction = new Order();
     $transaction->setTransaction($userId, $driverId, $pickup, $destination, $date, $rating, $comment);
-    //header('Location: ../view/dashboard.php?id=1');
-    echo "berhasil";
+    header('Location: ../view/dashboard.php?id='.$userId);
+    //echo "berhasil";
 }
diff --git a/model/order.php b/model/order.php
index 42a6c62e..a2d2e1b7 100644
--- a/model/order.php
+++ b/model/order.php
@@ -12,9 +12,8 @@ class Order {
     function setTransaction($userId, $driverId, $pickup, $destination, $transactionDate, $rating, $comment){
         $con = mysqli_connect('localhost','root', '', 'projekers');
         mysqli_select_db($con, 'projekers');
-        $sql = 'INSERT INTO transaction(user_id, driver_id, pickup, destination, date, rating, comment) VALUES('
-                . $userId .','. $driverId .','. $pickup .','. $destination.','. $transactionDate.','.$rating.','
-                . $comment.')';
+        $sql = 'INSERT INTO transaction(user_id, driver_id, pickup, destination, rating, comment, date) values('.
+                $userId.','.$driverId.',"'.$pickup.'","'.$destination.'",'.$rating.',"'.$comment.'","'.$transactionDate.'")';
         mysqli_query($con, $sql);
         mysqli_close($con);
     }
-- 
GitLab