-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceklogin.php
37 lines (32 loc) · 1.02 KB
/
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
29
30
31
32
33
34
35
36
37
<?php
session_start();
// menghubungkan dengan koneksi
include 'koneksi.php';
// menangkap data yang dikirim dari form
$username = $_POST['username'];
$password = $_POST['password'];
// menyeleksi data admin dengan username dan password yang sesuai
$guru = mysqli_query($db,"select * from guru where username='$username' and password='$password'");
$siswa = mysqli_query($db,"select * from siswa where username='$username' and password='$password'");
// menghitung jumlah data yang ditemukan
$cekguru = mysqli_num_rows($guru);
$ceksiswa = mysqli_num_rows($siswa);
//Jika Guru yang login
if($cekguru > 0){
$_SESSION['username'] = $username;
$_SESSION['status'] = "login";
//menuju ke halaman index guru
header("location:guru/indexguru.php");
}
//Jika Murid Yang Login
else if($ceksiswa > 0){
$_SESSION['username'] = $username;
$_SESSION['status'] = "login";
//menuju ke halaman index siswa
header("location:siswa/indexsiswa.php");
}
else{
//Login Gagal
header("location:login.php?pesan=gagal");
}
?>