From 544070dc1cdac80d9b0d208a7a11db73fc3e32a6 Mon Sep 17 00:00:00 2001
From: freedomfeather <fadlurohmanakmal@rocketmail.com>
Date: Fri, 6 Oct 2017 18:50:18 +0700
Subject: [PATCH] Memperbaiki prosedur menambahkan lokasi driver

---
 profile/edit_location.php  | 4 ++--
 profile/profile.php        | 4 +++-
 profile/updateLocation.php | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/profile/edit_location.php b/profile/edit_location.php
index a4798f93..a7f7f92e 100644
--- a/profile/edit_location.php
+++ b/profile/edit_location.php
@@ -32,9 +32,9 @@
         </div>
         <div class="add_loc_frame">
             <h2> Add New Location</h2>
-            <form name="add_location" action="">
+            <form name="add_location" action="updateLocation.php" method="POST">
                 <input type="text" name="new_location">
-                <input type="text" name="hidden_userid" style="display: none;">
+                <input type="text" id="hidden_userid" name="hidden_userid" style="display: none;">
                 <input type="submit" value="ADD" class="button green add">
             </form>
         </div>
diff --git a/profile/profile.php b/profile/profile.php
index 7b747df9..4ea93cd7 100644
--- a/profile/profile.php
+++ b/profile/profile.php
@@ -40,7 +40,9 @@
                         echo "</br><strong>".$row['username']."</strong></br>";
                         echo $row['name']."</br>";
                         if ($row['status'] == "driver") {
-                            echo "driver | Rating (xxx Votes)</br>";
+                            echo "Driver | Rating (xxx Votes)</br>";
+                        } else {
+                            echo "No-Driver</br>";
                         }
                         echo $row['email']."</br>";
                         echo $row['phone']."</br>";
diff --git a/profile/updateLocation.php b/profile/updateLocation.php
index fd64cf60..e2468caf 100644
--- a/profile/updateLocation.php
+++ b/profile/updateLocation.php
@@ -4,9 +4,9 @@
             include '../database/dbconnect.php';
             $user_id = $_POST['hidden_userid'];
             $new_loc = $_POST['new_location'];
-            $query = mysqli_query($con,"INSERT INTO user (driver_id,pref_loc) VALUES ('$user_id', '$new_loc')") or die(mysqli_error());
+            $query = mysqli_query($con,"INSERT INTO driver_prefloc (driver_id,pref_loc) VALUES ('$user_id', '$new_loc')") or die(mysqli_error($con));
             if ($query) {
-                header("Location: ../profile/profile.php?id=$user_id");
+                header("Location: edit_location.php?id=$user_id");
             }
         }
     }
-- 
GitLab