-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
85 lines (75 loc) · 2.45 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
<!--
Group: SCAD (Sami, Camille, Angelo, and Dan)
Purpose: Login page for TutorHub
Created: 2018-03-06 by Angelo
Modified: 2018-03-07 by Angelo
-->
<?php
$pagetitle = "Tutor Login";
require_once("inc/auth.php");
require_once("inc/header.php");
require_once('inc/validate.php');
$login_error = false;
if ($session) {
header("location:index.php");
} else if (isset($_POST['submit'])) {
if(test_email($_POST['email'])){
$try_email = $_POST['email'];
}else{
$login_error = true;
}
if(test_password($_POST['password'])){
$try_pwd = $_POST['password'];
}else{
$login_error = true;
}
$info = attemptLogin($try_email, $try_pwd);
if ($info) {
$_SESSION['UserData']['Username'] = htmlspecialchars($info[0]);
$_SESSION['UserData']['Avatar'] = htmlspecialchars($info[1]);
header("location:index.php");
} else {
$login_error = true;
}
}
if ($login_error) {
echo "
<div id='login-error-modal' class='modal fade'>
<div class='modal-dialog modal-dialog-centered'>
<div class='modal-content alert alert-danger'>
<div class='modal-header'>
<div>Login Failed</div>
<button type='button' class='close' data-dismiss='modal'>×</button>
</div>
<div class='modal-body'>
Invalid login credentials. Please try again.
</div>
</div>
</div>
</div>
";
echo "<script>$('#login-error-modal').modal('show');</script>";
}
?>
<section class="container-fluid main h-100 with-background">
<div class="row h-100 justify-content-center align-items-center">
<div class="col-lg-4 col-md-8 col-xxs-12">
<form class="form-whitebox" method="post">
<h4 class="text-center">Tutor Sign In</h4>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<br>
<div class="text-center mt-3">
<button type="submit" class="btn btn-primary" name="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
<?php require 'inc/footer.php'; ?>