This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_login.php
199 lines (182 loc) · 9.48 KB
/
user_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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
ob_start();
session_start();
?>
<?php
header('Location: index.php');
?>
<!DOCTYPE html>
<html>
<head>
<?php include_once('./PartialViews/main_head.php') ?>
<?php include_once('./config.php'); ?>
<style>
html {
background: #000;
}
body {
background-image: url('./AppData/Images/about_cover.jpg');
background-blend-mode: overlay;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.error {
color: #ffb300;
font-weight: 100;
font-size: smaller;
}
.nav-btn {
position: absolute;
right: 30px;
width: 100px;
}
#loginBtn {
font-weight: bolder;
}
#loginBtn:hover {
color: #273746;
background-color: #fff;
}
</style>
<script>
$(document).ready(function(){
// $('.page-footer').addClass('fixed-bottom');
});
</script>
</head>
<body>
<nav class="navbar sticky-top navbar-expand-lg navbar-dark">
<a class="navbar-brand d-flex" style="align-items:baseline;" href="index.php">
<img src="./AppData/Images/Integration_logo.png" width="30px" style="display:flex-inline; margin-right:15px;">
<h3 style="display:flex-inline; margin-right:40px;">Integration</h3>
</a>
<div class="form-inline">
<a class="btn nav-btn rounded-pill" href="user_signup.php">Signup</a>
</div>
</nav>
<div class="container" style="max-width:500px">
<div class="card card-login mx-auto my-5 rounded">
<div class="card-header lead" style="background:black;"><span style="font-family: 'Lobster';">Login to your account of Integration</span></div>
<div class="card-body" style="background: rgba(0,0,80,1);">
<!-- Login Form -->
<form name="userlogin" id = "userlogin" action="#">
<div class="form-group">
<div class="form-label-group">
<label for="email">Your Registered Email Address</label>
<input type="text" name = "email" id="email" class="form-control" placeholder="Email Address" autofocus="autofocus">
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<label for="pass">Password</label>
<input type="password" name="pass" id="pass" class="form-control" placeholder="Password">
</div>
</div>
<input class="btn btn-primary btn-block" id="loginBtn" type="submit" name="submit" value="Login">
</form>
<!-- Login Form -->
</div>
</div>
</div>
<?php include_once('./PartialViews/main_footer.php')?>
<!-- page level script -->
<script>
$(document).ready(function(){
var RootPathHost = '<?php echo($HTTP_HOST); ?>';
$('#userlogin').validate({
rules: {
email: "required",
pass: "required",
},
// Specify validation error messages
messages: {
email: "Please enter your registered email address",
pass: "Please enter your password",
},
submitHandler: function (form) {
form.submit();
}
});
$('#loginBtn').click(function(e) {
var ret = $('#userlogin').valid();
//console.log(ret);
e.preventDefault();
if (ret) {
var formElement = document.querySelector("#userlogin");
var formData = new FormData(formElement);
$.ajax({
url: 'https://www.isical.ac.in/~integration/Controller/userlogin_controller.php',
enctype: 'multipart/form-data',
data: formData,
processData: false,
contentType: false,
type: "POST",
success: function(data) {
var arr = data.split("||||");
var retval = arr[arr.length - 1];
console.log(retval);
if (parseInt(retval) > 0) {
$.alert({
title: 'Logged In',
content: 'You have sucessfully logged in to your account. Click OK to continue.',
buttons : {
OK: function () {
window.location.replace(RootPathHost+'/index.php');
}
}
});
} else if (parseInt(retval) == -1) {
$.alert({
title: 'Password Mismatched',
content: 'Looks like you typed your password wrong. Please try again!',
buttons : {
OK: function () {
},
}
});
} else if (parseInt(retval) == 0){
$.alert({
title: 'Not Signed Up Yet?',
content: 'Looks like you have not signed up as an user. Click Sign Up or proceed as an Guest user!',
buttons : {
SignUp: function () {
window.location.replace(RootPathHost+'/user_signup.php');
},
Proceed_As_Guest: function() {
window.location.replace(RootPathHost+'/index.php');
}
}
});
}
else {
$.alert({
title: 'Error',
content: 'Looks like there is a technical problem. Please try again later!',
buttons : {
OK: function () {
window.location.replace(RootPathHost+'/index.php');
}
}
});
}
},
error: function(data) {
$.alert({
title: 'Error',
content: 'Looks like there is a technical problem. Please try again later!',
buttons : {
OK: function () {
window.location.replace(RootPathHost+'/index.php');
}
}
});
}
});
}
});
});
</script>
<!--page level script-->
</body>
</html>