-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheat.php
126 lines (103 loc) · 4.22 KB
/
eat.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
<?php
require_once './api/connection.php';
if (!isset($_SESSION)) {
session_start();
}
if (!$_SESSION['loggedin'] || $_SESSION['usertype'] != 's') {
header("Location: login.php");
}
$Date = date("Y/m/d");
$Day = date("l");
$uid = $_SESSION['id'];
$eatingState = true;
$sql = "select * from adds where id = $uid and day = CURRENT_DATE();";
$res = $conn->query($sql);
if ($res && $row = $res->fetch_assoc()) {
if($row['stat'] == "F")
$eatingState = false;
} else { // insert
$sql = "insert into adds values ($uid, 'T', CURRENT_DATE());";
$res = $conn->query($sql);
$eatingState = true;
}
if(isset($_POST['back'])) {
header("Location: s.php");
}
if(isset($_POST['yesE']))
{
echo "fdd";
$sql = "update adds set stat = 'T' where id = $uid and day = CURRENT_DATE();";
$res = $conn->query($sql);
$eatingState = true;
header("Location: s.php");
}
if(isset($_POST['noE']))
{
$sql = "update adds set stat = 'F' where id = $uid and day = CURRENT_DATE();";
$res = $conn->query($sql);
$eatingState = false;
header("Location: s.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8" />
<title>NIT Andhra Pradesh MMS</title>
<link rel="stylesheet" href="./css/s.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
</head>
<body style=" overflow:scroll;">
<div class="alert alert-success" role="alert">
Welcome to NIT AP MMS Dashboard <?php echo $_SESSION['name']; ?>
<form action="s.php" method="post" style="float: right;">
<input type="hidden" value="m" name="logout">
<button type="submit" class="btn btn-danger">Logout</button>
</form>
</div>
<div id="content">
<form action="eat.php" method="post" style="float: left;">
<input type="hidden" value="m" name="back">
<button type="submit" class="btn btn-primary">Back</button>
</form>
<div class="container" style="align-content: center;">
<div class="card text-center">
<div class="card-header">
Will you be eating in mess today
</div>
<div class="card-body">
<?php if ($eatingState) : ?>
<h5 class="card-title">Present State: Yes</h5>
<?php endif; ?>
<?php if (!$eatingState) : ?>
<h5 class="card-title">Present State: No</h5>
<?php endif; ?>
<p class="card-text">Update your status and help us save food</p>
<form method="POST" action="eat.php" style="float: right;">
<div class="form-group">
<input type="hidden" value="T" name="yesE" id ="yesE">
</div>
<button type="submit" class="btn btn-success">Yes</button>
</form>
<form method="POST" action="eat.php" style="float: left;">
<div class="form-group">
<input type="hidden" value="F" name="noE" id ="noE">
</div>
<button type="submit" class="btn btn-danger">No</button>
</form>
<br>
<br>
<br>
</div>
<div class="card-footer text-muted">
<?php echo $Date?> | <?php echo $Day?>
</div>
</div>
</div>
</div>
<script src="./js/student/s.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>