-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceklogin.php
28 lines (25 loc) · 943 Bytes
/
ceklogin.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
<?php
session_start();
$conn = mysqli_connect('localhost:3306','raicabka_admin','GPhsKtQvjQzY','raicabka_pendaftaran_pramuka');
$username = stripslashes($_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'];
header('location:admin');
}else if($data['role'] == 'owner'){
$_SESSION['role'] = 'owner';
$_SESSION['username'] = $data['username'];
$_SESSION['user_id'] = $data['id_user'];
header('location:user/pendaftar.php');
}
}else{
$msg = 'Username Atau Password Salah';
header('location:index.php?msg='.$msg);
}