-
Notifications
You must be signed in to change notification settings - Fork 11
/
login.php
55 lines (48 loc) · 1.46 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
<?php include 'lib.php';
$in = testLogin();
print_header("Login");
?>
<div class="grid_10 suffix_1 prefix_1">
<div id="gatherling_main" class="box">
<div class="uppertitle"> Login to Gatherling </div>
<?php if (isset($_POST['mode'])) { print_loginFailed(); } ?>
<form action="login.php" method="post">
<table class="form" align="center" style="border-width: 0px" cellpadding="3">
<tr><th>MTGO Username</th>
<td><input type="text" name="username" value=""></td></tr>
<tr><th>Gatherling Password</th>
<td><input type="password" name="password" value="">
</td></tr>
<tr><td> </td></tr>
<tr><td colspan="2" class="buttons">
<input type="submit" name="mode" value="Log In"><br />
Please <a href="register.php">Click Here</a> if you need to register.
</td> </tr>
</table>
</form>
</div> <!-- gatherling_main -->
</div> <!-- grid 10 pre 1 suff 1 -->
<?php print_footer(); ?>
</div> <!-- container -->
</body>
</html>
<?php
function print_loginFailed() {
echo "<span class=\"error\"><center>Incorrect username or password. Please try again.\n";
echo "</center></span><br />";
}
function testLogin() {
$success = 0;
if(isset($_POST['username']) && isset($_POST['password'])) {
$auth = Player::checkPassword($_POST['username'], $_POST['password']);
if ($auth) {
session_start();
header("Cache-control: private");
$_SESSION['username'] = $_POST['username'];
header("location: player.php");
$success = 1;
}
}
return $success;
}
?>