-
Notifications
You must be signed in to change notification settings - Fork 0
/
signin.php
41 lines (36 loc) · 1.29 KB
/
signin.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
<?php
header('Content-type: application/json');
include 'connect.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// declare + assign
$email = $_POST['email'];
$password = $_POST['password'];
// check data login
// SELECT * FROM user WHERE email = '$username'
$sql = "SELECT * FROM user WHERE email = ? LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->execute([$email]);
$_SESSION['useremail'] = $email;
while($rowData = $stmt->fetch()){
$hashed_pw = hash('sha512',$password);
$nama = $rowData["nama"];
if (hash('sha512', $rowData['salt']. $hashed_pw) === $rowData['password']){
$_SESSION['email'] = $email;
$_SESSION['nama'] = $nama;
$_SESSION['statusJabatan'] = 'member';
if($rowData['ketua'] == 1){
$_SESSION['statusJabatan'] = 'ketua';
}
if($_SESSION['email'] === 'admin@gmail.com'){
echo json_encode(['location' => 'admin_home.php']);
}
else{
echo json_encode(['location'=>'user_home.php']);
}
}
else{
echo json_encode(['notif'=>'Email atau Password Salah!']);
}
}
}
?>