-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfunction.php
More file actions
41 lines (30 loc) · 993 Bytes
/
function.php
File metadata and controls
41 lines (30 loc) · 993 Bytes
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
<?php
session_start();
$koneksi = mysqli_connect("localhost","root","","inventory");
// login
if(isset($_POST['login'])){
$username = $_POST['uname'];
$password = $_POST['psw'];
$cekuser = mysqli_query($koneksi, "select * from akses where username='$username' and password='$password'");
$hitung = mysqli_num_rows($cekuser);
if($hitung>0){
$ambildatarole = mysqli_fetch_array($cekuser);
$role = $ambildatarole['role'];
if($role=='admin'){
$_SESSION['log'] = 'Logged';
$_SESSION['role'] = 'Admin';
$_SESSION['uname'] = $username;
$_SESSION['role'] = $role;
header('location:./admin');
}else{
$_SESSION['log'] = 'Logged';
$_SESSION['role'] = 'User';
$_SESSION['uname'] = $username;
$_SESSION['role'] = $role;
header('location:./user');
}
} else{
echo 'data tidak ada';
}
}
?>