diff --git a/controller/edit-prefered-location.php b/controller/edit-prefered-location.php new file mode 100644 index 0000000000000000000000000000000000000000..b4ae86a6b70419c8dce0703d02884eb4fb083811 --- /dev/null +++ b/controller/edit-prefered-location.php @@ -0,0 +1,20 @@ +<?php + +/* Model */ +include "../model/user.php"; + +//TODO: tambahin redirect klo get kosong + +$user = new User; +$user_id = $_GET['id']; +$result = $user->getUserById($user_id); +header('Content-Type: text/xml'); +$xml = '<user>'; +while($row = mysqli_fetch_array($result)){ + $xml = $xml . '<name>' . $row['name'] . '</name><username>' . $row['username'] . + '</username><email>' . $row['email'] . '</email><image>' . $row['image'] . + '</image><phone>' . $row['phone'] . '</phone><driver>' . $row['isDriver'] . '</driver>'; +} +$xml = $xml . '</user>'; + +print $xml; \ No newline at end of file diff --git a/controller/profile.php b/controller/profile.php index 922bc10243c289cdc1500425e7ff94084202136d..b4ae86a6b70419c8dce0703d02884eb4fb083811 100644 --- a/controller/profile.php +++ b/controller/profile.php @@ -17,5 +17,4 @@ while($row = mysqli_fetch_array($result)){ } $xml = $xml . '</user>'; -print $xml; - +print $xml; \ No newline at end of file diff --git a/model/user.php b/model/user.php index 25a3324302889d07a89474a6b3a40083c7c457e5..8f69fea160e4e20021dde8cafa7b0ebc2c6b5ff9 100644 --- a/model/user.php +++ b/model/user.php @@ -27,4 +27,23 @@ class User { mysqli_close($con); return $result; } + + function getPrefLocById($id){ + $con = mysqli_connect('localhost','root','','projekers'); + mysqli_select_db($con, 'projekers'); + $sql = "SELECT location FROM user WHERE id=" . $id; + $result = mysqli_query($con, $sql); + mysqli_close($con); + return $result; + } + + function getIdByUsernamePassword($username, $password){ + $con = mysqli_connect('localhost','root','','projekers'); + mysqli_select_db($con, 'projekers'); + $sql = "SELECT id FROM user WHERE username=" . $username . " and password=" . $password; + $result = mysqli_query($con, $sql); + mysqli_close($con); + return $result; + + } } \ No newline at end of file