-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
102 lines (98 loc) · 3 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
include('./db_connect.php');
ob_start();
// if(!isset($_SESSION['system'])){
$system = $conn->query("SELECT * FROM system_settings")->fetch_array();
foreach($system as $k => $v){
$_SESSION['system'][$k] = $v;
}
// }
ob_end_flush();
?>
<?php
if(isset($_SESSION['login_id']))
header("location:index.php?page=home");
?>
<?php include 'header.php' ?>
<body class="hold-transition login-page bg-black">
<div class="login-box">
<div class="login-logo">
<a href="#" class="text-white"><b><?php echo $_SESSION['system']['name'] ?></b></a>
</div>
<!-- /.login-logo -->
<div class="card">
<div class="card-body login-card-body">
<form action="" id="login-form">
<div class="input-group mb-3">
<input id="textfield1" type="email" class="form-control" name="email" placeholder="Email">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input id="textfield2" type="password" class="form-control" name="password" placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-8">
<div class="col-6">
<button id="guest-btn" type="submit" class="btn btn-warning btn-block" style="color:#fff;" name="guest">Guest</button>
</div>
</div>
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
</div>
<!-- /.login-card-body -->
</div>
</div>
<!-- /.login-box -->
<script>
$(document).ready(function(){
$('#guest-btn').click(function(){
document.getElementById("textfield1").style.display = "none";
document.getElementById("textfield2").style.display = "none";
$('#textfield1').val('guest@liquid');
$('#textfield2').val('guest');
});
$('#login-form').submit(function(e){
e.preventDefault()
start_load()
if($(this).find('.alert-danger').length > 0 )
$(this).find('.alert-danger').remove();
$.ajax({
url:'ajax.php?action=login',
method:'POST',
data:$(this).serialize(),
error:err=>{
console.log(err)
end_load();
},
success:function(resp){
if(resp == 1){
location.href ='index.php?page=home';
}else{
$('#login-form').prepend('<div class="alert alert-danger">Username or password is incorrect.</div>')
end_load();
}
}
})
})
})
</script>
<?php include 'footer.php' ?>
</body>
</html>