-
Notifications
You must be signed in to change notification settings - Fork 0
/
oldindex.php
411 lines (295 loc) · 11.9 KB
/
oldindex.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<?php
session_start();
include "../forum-connection.php";
$err="";
$err1 = "";
if(isset($_POST['loginbtn'])){
$username=$_POST["user_name"];
$password=$_POST["Password"];
$username=mysqli_real_escape_string($con,$username);
$password=mysqli_real_escape_string($con,$password);
//$username=testfunc($username);
//$password=testfunc($password);
$query="select * from user where username='$username' and password='$password' and active='1'";
$result=mysqli_query($con,$query);
$count=mysqli_num_rows($result);
if($count == 1)
{
$rows = mysqli_fetch_assoc($result);
$_SESSION["usertype"] = $rows["type"];
$_SESSION["user_name"]=$username;
$_SESSION["password"]=$password;
header("location: home.php");
}
else
{
$err="Invalid username or password or account is not activated.";
}
}
if(isset($_POST['rgrbtn'])){
$err1 = 0;
$user_name=$_POST['username'];
$Password=$_POST['password'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$reg=$_POST['regno'];
$question=$_POST['squestion'];
$answer=$_POST['sanswer'];
$hash = md5( rand(0,1000) );
/*$query= "SELECT * FROM user WHERE username = '$username'";
$result1=mysqli_query($con,$query);
$query= "SELECT * FROM user WHERE email = '$email'";
$result2=mysqli_query($con,$query);
$query= "SELECT * FROM user WHERE reg_no = $reg";
$result3=mysqli_query($con,$query);*/
$user_name=mysqli_real_escape_string($con,$user_name);
$Password=mysqli_real_escape_string($con,$Password);
$fname=mysqli_real_escape_string($con,$fname);
$lname=mysqli_real_escape_string($con,$lname);
$email=mysqli_real_escape_string($con,$email);
$reg=mysqli_real_escape_string($con,$reg);
$answer=mysqli_real_escape_string($con,$answer);
// $user_name=testfunc($user_name);
// $Password=testfunc($Password);
// $fname=testfunc($fname);
//$lname=testfunc($lname);
// $email=testfunc($email);
//$reg=testfunc($reg);
$query= "INSERT INTO user(username,reg_no,f_name,l_name,email,password,time_created,question,answer,hash) values('$user_name','$reg','$fname','$lname','$email', '$Password',now(),'$question','$answer','$hash')";
$result=mysqli_query($con,$query);
$err = "Account Created Successfully";
if(!$result){
die('failed query'. mysqli_error($con));
}
//header("location: index.php");
$to = $email;
$subject = 'Signup | Email Verification';
$message = '
Thanks for signing up!
Your account has been created, you can login to your account after activating your account by clicking on the link below.
Please click this link to activate your account:
https://www.forum.netronixgiki.com/verify.php?email='.$email.'&hash='.$hash.'
';
$headers = 'From:[email protected]' . "\r\n";
mail($to, $subject, $message, $headers);
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="fontawesome-free-5.8.1-web/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lato|Raleway:500,700|Ubuntu" rel="stylesheet">
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/style.css">
<title>GIK FORUM</title>
</head>
<body>
<div class="container login-page">
<div class="row d-flex justify-content-center">
<div class="col-lg-12 col-md-12 col-sm-10">
<div class="form">
<h1 class=" title display-4 text-white text-center">GIK FORUM</h1>
<form class="register-form " method="post" action = "index.php">
<input type="text" id="fname" name= "fname" placeholder="First Name" required>
<input type="text" id="lname" name="lname" placeholder="Last Name" required>
<input type="text" id="regno" name="regno" placeholder="Reg Number eg:20xxxxx" maxlength="7" required>
<input type="text" id="username" name="username" placeholder="User Name" maxlength="11" required >
<input type="email" id="email" name="email" placeholder="Email eg:[email protected]" maxlength="20" required>
<select id="squestion" name="squestion" class="browser-default custom-select mb-3" required>
<option value="">Select Question</option>
<option value="1">What is your Favorite color?</option>
<option value="2">What is your pet's name?</option>
<option value="3">What is your father's name?</option>
<option value="3">In which city you were born?</option>
</select>
<input type="text" id="sanswer" name="sanswer" placeholder="Answer" maxlength="40" required>
<input type="password" id="pass" name="password" placeholder="Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Password must contain at least one number, one uppercase, one lowercase letter and at least 8 characters." required>
<input type="password" id="cpass" name="confirmpassword" placeholder="Re-enter Password" required>
<p id='availability'></p>
<button type="submit" class="btn btn-success" id="registerbtn" name="rgrbtn">Create</button>
<p class="message text-white"><br>Already Registered ? <a href="#">Login Here !</a></p>
</form>
<form class="login-form" action="index.php" method="post">
<input type="text" id="user_name" name="user_name" placeholder="User Name" required>
<input type="password" id="Password" name="Password" placeholder="Password" required>
<p class= "<?php if($err != "" && $err !="Account Created Successfully" ) {echo 'alert-danger h6 py-2 mb-0 rounded-sm';} elseif($err == "Account Created Successfully") {echo 'alert-success h6 py-2 mb-0 rounded-sm';}?>"><?php if($err != "") {echo $err;} ?></p>;
<button type="submit" class="btn btn-success mt-0" id="loginbtn" name="loginbtn">Login</button>
<p class="message text-white"><br>Not Registered ? <a href="#"><br>Click Here To Register !</a></p>
<!-- Forgot password modal Button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal1">
Forgot Password?
</button>
<button type="button" class="btn btn-primary my-3">
<a class="text-white" href="guest.php">Enter as Guest</a>
</button>
</form>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div class="modal" id="myModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Forgot Password</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<form id="forgotform" method="POST">
<div class="input-group mb-3 form-group">
<div class="input-group-prepend">
<span class="input-group-text">Username</span>
</div>
<input type="text" id="frgt" name="forgotusername" class="form-control" required>
</div>
</form>
<div class=" justify-content-center" id="uname_response">
<button type="submit" id="forgotbtn" name="forgotbtn" onclick="check()" class="btn btn-primary">Submit</button>
</div>
<script>
function check()
{
var name= document.getElementById("frgt").value;
$.ajax({
url: 'forgotpass.php',
type: 'post',
data: {name},
success: function(response){
$("#uname_response").html(response);
}
});
}
</script>
<!--<div class="input-group mb-3 form-group">
<div class="input-group-prepend">
<span class="input-group-text">Security Question</span>
</div>
<input type="text" name="securityquestion" class="form-control" required>
</div>
<div class="input-group mb-3 form-group">
<div class="input-group-prepend">
<span class="input-group-text">Answer</span>
</div>
<input type="text" name="securityanswer" class="form-control" required>
</div -->
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- End of modal -->
<div class="container-fluid">
<footer class=" footer">
<div class="footer-copyright text-center py-3 text-white">© 2019 Copyright:
Riaz-ul-Haq | Uzair Ahmed | Muhammad Inam |
Gulfam Hussain
</div>
</footer>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="./js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="./js/jquery-3.3.1.min.js"></script>
<script>
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"}, "slow");
});
var password = document.getElementById("pass"),
confirm_password = document.getElementById("cpass");
function validatePassword(){
if(password.value != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
}
else {
confirm_password.setCustomValidity('');
}
}
var reg = document.getElementById("regno");
var numbers = /^2{1}0{1}[0-9]{5}$/;
var email = document.getElementById("email");
var checkemail = "";
function validate_email(){
if(email.value != checkemail)
{
email.setCustomValidity("Invalid Email Or Email Dosent Match Reg No.");
}
else
{
email.setCustomValidity("");
}
}
function validateregno()
{
if(!reg.value.match(numbers))
{
reg.setCustomValidity("Invalid Format");
}
else
{
checkemail = "u" + document.getElementById("regno").value + "@giki.edu.pk";
reg.setCustomValidity("");
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
reg.onkeyup=validateregno;
email.onkeyup = validate_email;
</script>
<script>
$('#username').blur(function(){
var username= $(this).val();
$.ajax({
url: "checkattributes.php",
method: "POST",
data: {USER_NAME: username},
dataType: "text",
success:function(html)
{
$('#availability').html(html);
}
});
});
$('#email').blur(function(){
var email= $(this).val();
$.ajax({
url: "checkattributes.php",
method: "POST",
data: {EMAIL: email},
dataType: "text",
success:function(html)
{
$('#availability').html(html);
}
});
});
$('#regno').blur(function(){
var regno = $(this).val();
$.ajax({
url: "checkattributes.php",
method: "POST",
data: {REGNO: regno},
dataType: "text",
success:function(html)
{
$('#availability').html(html);
}
});
});
</script>
</body>
</html>