-
Notifications
You must be signed in to change notification settings - Fork 0
/
gift_Certificates.txt
178 lines (131 loc) · 4.26 KB
/
gift_Certificates.txt
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
<html>
<head>
<style>
#loginbox{
padding: 15px;
}
#categories{
background-color:white;
}
body{
background-image: url('inn.jpg');
background-attachment: fixed;
}
#container2{
box-shadow: 12px 12px 12px black;
border: solid black 1px;
width: 800px;
background-color: #9cc4db;
border-radius: 25px;
padding: 25px;
margin-top:25px;
}
h1, h2, h3{
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<center>
<div id="container2">
<a href="mainMenu.php">Back to Main Menu</a>
<br>
<h1>GIFT CERTIFICATES</h1>
<!--Table of prexisting gift certificates begins-->
<table id = "categories" border="3" cellpadding="2" cellspacing="2" summary="" width="500px">
<tr>
<th>Gift Certificate ID #</th>
<th>Gift Amount</th>
<th>Recipient</th>
<th>Occasion</th>
</tr>
<?php
//begin session
session_start();
//identify current user
echo "<h2>Current User: ".$_SESSION["user_Name"]."</h2>";
//if submit is pressed, and a new gift certificate is trying to be made...
if (isset($_POST['submitrequest'])){
include 'sis_include_DB.php';
//include database
//assign post variables to variables for the INSERT query
$new_Amount = $_POST['gift_Amount'];
$new_Recipient = $_POST['gift_Recipient'];
$new_Occasion = $_POST['gift_Occasion'];
$new_User = $_SESSION["user_Id"];
//if all the fields are full
if(!empty($new_Amount) && !empty($new_Recipient) && !empty($new_Occasion)) {
//query to insert
$query = "INSERT INTO gift_certificates VALUES( '','$new_Amount','$new_Recipient','$new_Occasion','$new_User')";
$result = mysql_query( $query );
//check for success
if(! $result )
{
die('Could not enter data: ' . mysql_error());
}
else
{
//if success, close mysql link and reload page with new entry listed
echo "Gift Certificate Request Made\n";
mysql_close($link);
header('Location: gift_Certificates.php');
}
}
else{
//inform of failure
echo "<h3>All fields are not complete</h3>\n";
}
}
include 'sis_include_DB.php';
//query for gift certificates
$query = "SELECT gift_certificates.giftcertificate_Id, gift_certificates.gift_Amount, gift_certificates.gift_Recipient, gift_certificates.gift_Occasion FROM gift_certificates WHERE fk_user_Id = ".$_SESSION['user_Id']."";
$result = mysql_query($query);
//print gift certificates for that user into table
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>";
echo $row['giftcertificate_Id'];
echo "</td>";
echo "<td>";
echo $row['gift_Amount'];
echo "</td>";
echo "<td>";
echo $row['gift_Recipient'];
echo "</td>";
echo "<td>";
echo $row['gift_Occasion'];
echo "</td>";
echo "</tr>";
}
?>
</table>
<br/>
<br/>
<h1>New Gift Certificate</h1>
<form action = "gift_Certificates.php" method = "post">
<table align = "center" border="0">
<tr>
<td>Gift Amount:</td>
<td><input type = "text" name = "gift_Amount" value = ""/></td>
</tr>
<tr>
<td>Recipient:</td>
<td><input type = "text" name = "gift_Recipient" /></td>
</tr>
<tr>
<td>Occasion:</td>
<td><input type = "text" name = "gift_Occasion" /></td>
</tr>
<tr>
<td colspan = 2><input type = "submit" name = "submitrequest" value = "Submit Request"></td>
<!--submit button for new gift certificate -->
</tr>
</table>
</form>
<img src='gift_certificate.jpg' align='center' />
</div>
<br/>
<br/>
</center>
</body>
</html>