I have php code for login, it is worked if i input just username and password, but i need to check it with column hak_akses. For example if i login with hakakses = Dosen, the response says "Login Berhasil", if i login with hakakses = TU, the response says "Login Failed"
This is my code login php
<?php
$con = new mysqli("localhost","root","","komplain");
if($con->connect_error)
{
die("Connection Failed: " .$con->connect_error);
}
$response = array();
if(isset($_GET['apicall']))
{
switch ($_GET['apicall']) {
case 'signup':
# code...
break;
case 'login':
if(isParameterAvailable(array('username','password')))
{
$username = $_POST['username'];
$password = password_hash($_POST['password']);
$stmt = $con->prepare("SELECT id_user, username, email, no_telp FROM user WHERE username = ? AND password = ?");
$stmt->bind_param("ss",$username,$password);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows > 0)
{
$stmt->bind_result($id,$username,$email,$no_telp);
$stmt->fetch();
$user = array(
'id'=>$id,
'username'=>$username,
'email'=>$email,
'no_telp'=>$no_telp
);
$response['error'] = false;
$response['message'] = "Login Berhasil";
$response['user'] = $user;
}
else
{
$response['error'] = false;
$response['message'] = "Username / Password Salah";
}
}
break;
default:
$response['error'] = true;
$response['message'] = 'Invalid Operation Called';
}
}
else
{
$response['error'] = true;
$response['message'] = 'Invalid API call';
}
echo json_encode($response);
?>
This is my database enter image description here
This is response from postman enter image description here
My question is what should i do if i need to check login with hakakses(level user) ? This code is just simulation, i am not using this code for my project, so i want to know how to login with multilevel user base on my code
Sorry for my English
Thank You