-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
48 lines (43 loc) · 1.74 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require 'koneksi.php';
if (isset($_POST["login"])){
session_start();
$username = $_POST["username"];
$password = $_POST["password"];
$result = mysqli_query($koneksi, "SELECT *
FROM user
WHERE username = '$username'");
// echo(strcmp($row["username"], "admin"));
//cek username
if(mysqli_num_rows($result) > 0){
$row = mysqli_fetch_assoc($result);
//cek password
if(password_verify($password, $row["password"])){
if($row["level"] == "admin"){
$_SESSION['username'] = $username;
$_SESSION['level'] = "admin";
header("location: admin.php");
}
else if($row["level"] == "pegawai"){
$_SESSION['username'] = $username;
$_SESSION['level'] = "pegawai";
header("location: homepegawai.php");
}
else if($row["level"] == "pasien"){
$_SESSION['username'] = $username;
$_SESSION['level'] = "pasien";
header("location: home.php");
}
else{
header("location:loginpage.php?pesan=gagal");
}
}
// else{
// $error = true;
// }
else{
header("location:loginpage.php?pesan=gagal");
}
}
}
?>