-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
158 lines (145 loc) · 6.46 KB
/
index.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
<?php
session_start();
require_once("class.user.php");
$auth_user = new USER();
//if user's logged in redirect to dashboard
if ($auth_user->is_loggedin() !="") {
$auth_user->redirect_dashboard();
}
?>
<!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-sm-9 col-md-7 col-lg-5 mx-auto">
<div class="card card-signin my-5 ">
<h5 class="card-title text-center" id="f_text" style="background-color: #eb0506; padding: 15px; color: white; border-radius: 5px 5px 0px 0px;" >Sign In</h5>
<div class="card-body">
<hr style="margin-top: -30px;">
<div class="text-center msg">
<img src="assets/img/logo/logo.png" alt="Naic Logo" style="width: 100px;">
<h5>Naic Coastal National High School</h5>
<h3>Information System</h3>
<small id="f_stext">Login here using your username and password</small>
</div>
<div id="f_login">
<form class="form-signin" id="login_form" method="POST">
<div class="form-label-group">
<input type="text" id="inputUsername" class="form-control" placeholder="Username" name="login_user" required autofocus>
<label for="inputUsername">Username</label>
</div>
<div class="form-label-group">
<input type="password" id="inputPassword" class="form-control" placeholder="Password" name="login_password" required>
<label for="inputPassword">Password</label>
</div>
<input type="hidden" name="operation" value="submit_login">
<button class="btn btn-lg btn-primary btn-block" type="submit" style="background-color: #e91e63;border: none !important;" 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-label-group">
<input type="password" id="reg_studentnum" class="form-control" placeholder="Student Number" name="reg_studentnum" required>
<label for="acc_username">LRN Number</label>
</div>
<div class="form-row">
<div class="form-label-group col-md-6">
<input type="password" id="reg_password" class="form-control" placeholder="Password" name="reg_password" required>
<label for="acc_password">Password</label>
</div>
<div class="form-label-group col-md-6">
<input type="password" id="reg_cpassword" class="form-control" placeholder="Confirm Password" name="reg_cpassword" required>
<label for="acc_cpassword">Confirm Password</label>
</div>
</div>
<div class="form-label-group">
<input type="email" id="reg_email" class="form-control" placeholder="Email" name="reg_email" required>
<label for="acc_email">Email</label>
</div>
<input type="hidden" name="operation" value="submit_register">
<button class="btn btn-lg btn-primary btn-block" type="submit" style="background-color: #e91e63;border: none !important;" name="submit_register">Register</button>
<div class="text-center">
Already have an account? <a href="#" id="a_login">Login</a>
</div>
</form>
</div>
</div>
</div>
</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-action.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-action.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('Register Success');
$('#f_register').hide();
$('#f_login').show();
}
else{
alertify.alert(newdata.error).setHeader('Error Register');
}
}
});
});
$(document).on('click', '#a_sign', function(){
$('#f_text').text('Register');
$('#f_stext').text('Fill-up to register');
$('#f_login').hide();
$('#f_register').show();
});
$(document).on('click', '#a_login', function(){
$('#f_text').text('Login');
$('#f_stext').text('Login here using your username and password');
$('#f_login').show();
$('#f_register').hide();
});
</script>
</html>