forked from Fchaubard/WolfPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iAmHungryPage.php
77 lines (59 loc) · 1.62 KB
/
iAmHungryPage.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
<?php
if(file_exists("./formatting/header.php")){
include "./formatting/header.php";
}
?>
<body>
<div data-role="page">
<div data-role="header">
<h1>Welcome!</h1>
<a href="#" data-icon="check" id="logout" class="ui-btn-right">Logout</a>
</div><!-- /header -->
<div data-role="content">
<?php
$name = 0;
include("config.php");
$un_name = $_POST["username"];
$query = "SELECT * FROM users WHERE userName LIKE '$un_name'";
$result = mysql_query($query)or die(mysql_error());
$row = mysql_fetch_array($result);
if($row["password"] == $_POST["password"]){
$name=1;
$firstName = $row["firstName"];
$lastName = $row["lastName"];
}
?>
<?php
// This is a hack. You should connect to a database here.
if ($name==1) {
?>
<script type="text/javascript">
// Save the username in local storage. That way you
// can access it later even if the user closes the app.
localStorage.setItem('username', '<?=$_POST["username"]?>');
</script>
<?php
echo "<p>Welcome <strong>".$firstName."</strong>!</p>";
?>
<?php
if(file_exists("./formatting/timeInputs.php")){
include "./formatting/timeInputs.php";
}
?>
<?php
echo "<form action=\"mainPage.php\" method=\"post\"><input type=\"submit\" value=\"Join the Hungry!\"/></form>";
} else {
echo "<p>There seems to have been an error.</p>";
}
?>
</div><!-- /content -->
<script type="text/javascript">
$("#logout").click(function() {
localStorage.removeItem('username');
$("#form").show();
$("#logout").hide();
});
</script>
</div><!-- /page -->
</body>
</html>