-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication.php
183 lines (161 loc) · 6.27 KB
/
authentication.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
session_start();
if (isset($_SESSION['login_user'])) {
header('Location:index.php');
}
?>
<!doctype html>
<html lang="en">
<?php
include ('x-head.php')
?>
<body>
<?php
include('x-header.php');
?>
<div class="container">
<div class="row">
<div class="col" style=" border: 1px solid #1d8f1d; border-radius:5px 0px 0px 5px">
<div class="text-center" style="padding:20%">
<h2>SAKA</h2>
<img src="assets/img/icon1.png" width="80%">
</div>
</div>
<div class="col" style=" background-color: #f0f0f0; border: 1px solid #1d8f1d; border-radius:0px 5px 5px 0px;" >
<div class="text-center mb-4">
<img class="mb-4" src="assets/img/logo.png" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal" id="f_text">Login</h1>
</div>
<div id="f_login">
<form class="form-signin" id="login_form" method="POST">
<div class="form-label-group">
<input type="text" id="inputEmail" class="form-control" placeholder="Username" name="username" required autofocus>
<label for="inputEmail">Username</label>
</div>
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control" placeholder="Password" name="password" required>
<label for="inputPassword">Password</label>
</div>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<input type="hidden" name="operation" value="submit_login">
<button class="btn btn-lg btn-primary btn-block" type="submit" style="background-color: #1d8f1d" name="submit_login">Sign in</button>
<div class="text-center">
Don't have an account? <a href="#" id="a_sign">Sign up</a>
</div>
</form>
</div>
<div id="f_register">
<form class="form-signin" id="register_form" method="POST">
<div class="form-row">
<div class="form-group col-md-6">
<label for="acc_username">Username</label>
<input type="text" class="form-control" id="acc_username" name="acc_username" placeholder="" value="" required="">
</div>
<div class="form-group col-md-6">
<label for="acc_email">Email:</label>
<input type="email" class="form-control" id="acc_email" name="acc_email" placeholder="" value="" required="">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="acc_name">Full Name</label>
<input type="text" class="form-control" id="acc_name" name="acc_name" placeholder="" value="" required="">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="acc_pass" id="l_acc_pass">Password</label>
<input type="password" class="form-control" id="acc_pass" name="acc_pass" placeholder="" value="" required="">
</div>
<div class="form-group col-md-6">
<label for="acc_cpass" id="l_acc_cpass">Confirm:</label>
<input type="password" class="form-control" id="acc_cpass" name="acc_cpass" placeholder="" value="" required="">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="acc_add">Address</label>
<input type="text" class="form-control" id="acc_add" name="acc_add" placeholder="" value="" required="">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit" style="background-color: #1d8f1d" name="submit_register">Register</button>
<div class="text-center">
Already have an account? <a href="#" id="a_login">Login</a>
</div>
</form>
</div>
<p class="mt-5 mb-3 text-muted text-center">© <?php
$fromYear = 2019;
$thisYear = (int)date('Y');
echo $fromYear . (($fromYear != $thisYear) ? '-' . $thisYear : '');?> CVSU Main Indang - Saka, All rights reserved</p>
</div>
</div>
</div>
</body>
<?php
include('x-script.php');
?>
<script type="text/javascript">
$('#f_register').hide();
$(document).on('submit', '#login_form', function(event){
event.preventDefault();
$.ajax({
url:"data-login.php",
method:'POST',
data:new FormData(this),
contentType:false,
processData:false,
type: 'html',
success:function(data)
{
var newdata = JSON.parse(data);
if (newdata.success) {
alertify.alert(newdata.success).setHeader('Login Success');
window.location.assign("dashboard/");
}
else{
alertify.alert(newdata.error).setHeader('Error Login');
}
}
});
});
$(document).on('submit', '#register_form', function(event){
event.preventDefault();
$.ajax({
url:"data-register.php",
method:'POST',
data:new FormData(this),
contentType:false,
processData:false,
type: 'html',
success:function(data)
{
var newdata = JSON.parse(data);
console.log(newdata);
if (newdata.success) {
alertify.alert(newdata.success).setHeader('Successfully Register');
$('#f_login').show();
$('#f_register').hide();
}
else{
alertify.alert(newdata.error).setHeader('Register Error ');
}
}
});
});
$(document).on('click', '#a_sign', function(){
$('#f_text').text('Register');
$('#f_login').hide();
$('#f_register').show();
});
$(document).on('click', '#a_login', function(){
$('#f_text').text('Login');
$('#f_login').show();
$('#f_register').hide();
});
</script>
</html>