-
Notifications
You must be signed in to change notification settings - Fork 0
/
validatemeal.php
188 lines (151 loc) · 8.13 KB
/
validatemeal.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
<?php
session_start();
include "../../../connection_string.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>ZUMBA AIR</title>
<link rel="stylesheet" type="text/css" href="zumbacss.css">
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+KR|Pacifico" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script>
</head>
<?php
include "../../../connection_string.php"; //contains MySQL login information
mysql_select_db("ZumbaAir", $con);
$catresult = mysql_query("SELECT comname FROM Zumbacaterers");
echo '
<div id="banner">
<div class="logoimg">
<img src="zumbaairlogo.png" height="140px" width="140px";>
</div>
<div class="logobrand">
<p>THE PRIDE OF AIR TRAVEL</p>
</div>
</div>
<div class="transition"><a href="logout.php"><input type="button" value="Logout"></a></div>';
echo'<div id = "notes">' ;
echo "<ul style='list-style-type:none;'>";
echo'<li><form action="newmeal.php" method="GET">
<button class="button" type="submit" name="newmeal">New Request</button>
</form> </li> ' ;
echo'<li><form action="viewmeal.php" method="GET">
<button class="button" type="submit" name="Viewupdatemeal">View/Update Request</button>
</form> </li>' ;
echo'<li><form action="addcaterer.php" method="GET">
<button class="button" type="submit" name="addcaterer">Add new Caterer</button>
</form> </li>' ;
echo'<li><form action="searchcaterer.php" method="GET">
<button class="button" type="submit" name="updatecatererinfo">View / Update Caterer </button>
</form> </li>' ;
echo "</ul>";
echo "</div>";
echo'<div id = "welcomepage">' ;
echo "<p class='welcomenote'>Welcome ".$_SESSION['username']."</p>";
$airline = ($_REQUEST['airline']);
$flightnumber = ($_REQUEST['flightnumber']);
$flightdate = ($_REQUEST['flightdate']);
$origin = ($_REQUEST['origin']);
$destination = ($_REQUEST['destination']);
$caterer = ($_REQUEST['caterer']);
$flightdeck = ($_REQUEST['flightdeck']);
$cabin = ($_REQUEST['cabin']);
$avml = ($_REQUEST['avml']);
$chml = ($_REQUEST['chml']);
$dbml = ($_REQUEST['dbml']);
$gfml = ($_REQUEST['gfml']);
$hnml = ($_REQUEST['hnml']);
$ksml = ($_REQUEST['ksml']);
$lcml = ($_REQUEST['lcml']);
$lsml = ($_REQUEST['lsml']);
$vgml = ($_REQUEST['vgml']);
$regmeal = ($_REQUEST['regmeal']);
$mealrequest = ($_REQUEST['mealrequest']);
if(isset($mealrequest))
{
if ((!is_numeric($flightnumber)) || (!is_numeric($flightdeck)) || (!is_numeric($cabin)) || (!is_numeric($avml)) || (!is_numeric($chml)) || (!is_numeric($dbml)) || (!is_numeric($gfml)) || (!is_numeric($hnml)) || (!is_numeric($ksml)) || (!is_numeric($lcml)) || (!is_numeric($lsml)) || (!is_numeric($vgml)) || (!is_numeric($regmeal)))
{
echo ("<center><span style='color:red' font-size='15px'>**You have entered incorrect form of data!!**</span>");
}
else{
include "../../../connection_string.php"; //contains MySQL login information
mysql_select_db("ZumbaAir", $con);
$valmeal = mysql_query ("SELECT COUNT(*) as total FROM TestTable WHERE mealID = (CONCAT('$airline','$flightnumber','/','$flightdate'))");
$viewmeal = mysql_fetch_assoc($valmeal);
if (($viewmeal['total']) > 0)
{die ("<center><span style='color:red' font-size='15px'>**Meal for ".$airline.$flightnumber."/".$flightdate." already requested.!!**</span>");}
else{
$insertquery = mysql_query("INSERT INTO TestTable VALUES ((CONCAT('$airline','$flightnumber','/','$flightdate')), '$flightnumber', '$flightdate', '$origin', '$destination', '$caterer', '$flightdeck', '$cabin','$avml','$chml','$dbml','$gfml','$hnml','$ksml','$lcml','$lsml','$vgml','$regmeal')");
echo "<center>Information entered successfully! <br> <br>";
$mealsearchresult = mysql_query("SELECT * FROM TestTable WHERE mealID = (CONCAT('$airline','$flightnumber','/','$flightdate'))");
while($row = mysql_fetch_array($mealsearchresult)){
echo '<table id="mealtype">';
echo "<tr class='fshade'><td width='120' height='40'>Meal Id</td><td width='200'> " . $row['mealID'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>Flight Number</td><td>" . $row['flightnumber'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>Flight Date</td><td>" . $row['flightdate'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>Origin</td><td>" . $row['origin'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>Destination</td><td>" . $row['destination'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>Caterer</td><td>" . $row['caterer'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>Flight Deck</td><td>" . $row['flightdeck'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>Cabin</td><td>" . $row['cabin'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>AVML</td><td>" . $row['avml'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>CHML Code</td><td>" . $row['chml'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>DBML</td><td>" . $row['dbml'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>GFML</td><td>" . $row['gfml'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>HNML</td><td>" . $row['hnml'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>KSML</td><td>" . $row['ksml'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>LCML</td><td>" . $row['lcml'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>LSML</td><td>" . $row['lsml'] . "</td></tr>
<tr class='fshade'><td width='120' height='40'>VGML</td><td>" . $row['vgml'] . "</td></tr>
<tr class='sshade'><td width='120' height='40'>Regular Meal</td><td>" . $row['regmeal'] . "</td></tr></table><br><br>";
}
$catereremail = mysql_query("SELECT comemail FROM Zumbacaterers WHERE comname = '$caterer' ");
$viewcatereremail = mysql_fetch_assoc($catereremail);
$To = $viewcatereremail['comemail'];
$Subject = "Daily Meal Request";
$Message = "<html>
<head>
<style>
#mealtype{border-collapse:collapse;margin:auto;}
#mealtype, #mealtype tr ,#mealtype td{border:1px solid black;}
</style>
</head>
<body>
<p>Dear " .$caterer." Team, Please find the below Meal Request</p>
<table id='mealtype'>
<tr><td width='120' height='40'>Meal ID </td><td>" . $airline.$flightnumber."/".$flightdate. "</td></tr>
<tr><td width='120' height='40'>Flight Number</td><td>" . $airline . "</td></tr>
<tr><td width='120' height='40'>Flight Number</td><td>" . $flightnumber . "</td></tr>
<tr><td width='120' height='40'>Flight Date</td><td>" . $flightdate . "</td></tr>
<tr><td width='120' height='40'>Origin</td><td>" . $origin . "</td></tr>
<tr><td width='120' height='40'>Destination</td><td>" . $destination . "</td></tr>
<tr><td width='120' height='40'>Caterer</td><td>" . $caterer . "</td></tr>
<tr><td width='120' height='40'>Flight Deck</td><td>" . $flightdeck . "</td></tr>
<tr><td width='120' height='40'>Cabin</td><td>" . $cabin . "</td></tr>
<tr><td width='120' height='40'>AVML</td><td>" . $avml . "</td></tr>
<tr><td width='120' height='40'>CHML Code</td><td>" . $chml . "</td></tr>
<tr><td width='120' height='40'>DBML</td><td>" . $dbml . "</td></tr>
<tr><td width='120' height='40'>GFML</td><td>" . $gfml . "</td></tr>
<tr><td width='120' height='40'>HNML</td><td>" . $hnml . "</td></tr>
<tr><td width='120' height='40'>KSML</td><td>" . $ksml . "</td></tr>
<tr><td width='120' height='40'>LCML</td><td>" . $lcml . "</td></tr>
<tr><td width='120' height='40'>LSML</td><td>" . $lsml . "</td></tr>
<tr><td width='120' height='40'>VGML</td><td>" . $vgml . "</td></tr>
<tr><td width='120' height='40'>Regular Meal</td><td>" . $regmeal . "</td></tr>
</table>
</body>
</html>" ;
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$sendEmailresult = mail($To, $Subject, $Message, implode("\r\n", $headers));
}
}
}
?>
</div>
<div id="footer">
</br>
<b>© Zumba Air| [email protected] | </b></div>
</body>
</html>