-
Notifications
You must be signed in to change notification settings - Fork 8
/
cek_login.php
35 lines (33 loc) · 1.25 KB
/
cek_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
<?php
session_start();
$conn = mysqli_connect("localhost", "root", "", "db_laundry");
$username = $_POST['username'];
$password = md5($_POST['password']);
$query = "SELECT * FROM user WHERE username = '$username' AND password = '$password'";
$row = mysqli_query($conn, $query);
$data = mysqli_fetch_assoc($row);
$cek = mysqli_num_rows($row);
if ($cek > 0) {
if ($data['role'] == 'admin') {
$_SESSION['role'] = 'admin';
$_SESSION['username'] = $data['username'];
$_SESSION['user_id'] = $data['id_user'];
$_SESSION['outlet_id'] = $data['outlet_id'];
header('location:admin');
} else if ($data['role'] == 'kasir') {
$_SESSION['role'] = 'kasir';
$_SESSION['username'] = $data['username'];
$_SESSION['user_id'] = $data['id_user'];
$_SESSION['outlet_id'] = $data['outlet_id'];
header('location:kasir');
} else if ($data['role'] == 'owner') {
$_SESSION['role'] = 'owner';
$_SESSION['username'] = $data['username'];
$_SESSION['user_id'] = $data['id_user'];
$_SESSION['outlet_id'] = $data['outlet_id'];
header('location:owner');
}
} else {
$message = 'Username atau password salah!!!';
header('location:index.php?message=' . $message);
}