Skip to content
Snippets Groups Projects
Commit cf640f86 authored by Mikhael Artur Darmakesuma's avatar Mikhael Artur Darmakesuma
Browse files

Added getter for pref loc in user model

parent 172a0b18
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
<?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
......@@ -17,5 +17,4 @@ while($row = mysqli_fetch_array($result)){
}
$xml = $xml . '</user>';
print $xml;
print $xml;
\ No newline at end of file
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment