-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_items.php
More file actions
161 lines (129 loc) · 4.48 KB
/
create_items.php
File metadata and controls
161 lines (129 loc) · 4.48 KB
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
<?php
require_once('inc/startsession.php');
/////////////////////////////////////////////////////////////////////
//
// Written by Jim Garbe-- Dynamic Checksheet
//
/////////////////////////////////////////////////////////////////////
require_once('inc/appvars.php');
$Title="Creating Items";
require_once('inc/title.php');
?>
<?php
require_once("inc/functions.php.inc");
require_once('inc/connectvars.php');
// Generate the navigation menu
if (isset($_SESSION['username']) && ($_SESSION['status'] == 1)) {
}
else {
echo ' <a href="login.php">Log In As An Administrator(' . $_SESSION['username'] . ').</a><br />';
//echo ' <a href="signup.php">Sign Up</a>';
}
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Retrieve the user data from MySQL
$query = "SELECT user_id, first_name FROM _user WHERE first_name IS NOT NULL ORDER BY join_date DESC LIMIT 5";
$data = mysqli_query($dbc, $query);
mysqli_close($dbc);
?>
</div>
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!empty($_POST['Item_create']) && isset($_SESSION['username']) && ($_SESSION['status'] == 1)) { //if logged in, and form submitted
if (!empty($_POST['NewItem']) ) {
$NewItem=$_POST['NewItem'];
$PerishableItem=$_POST['PerishableItem'];
// Connect to the database
print("$PerishableItem");
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query="INSERT INTO Items VALUES ('0','$NewItem','$PerishableItem','','','','','')";
mysqli_query($dbc,$query) or die( "Unable to insert into Items:". mysqli_error());
echo "".$NewItem." created.<br>";
mysqli_close($dbc);
?>
<?php
print ("<center><a href='".HOME."'>HOME</a></center>\n");
print ("<center><a href=create_items.php>Create Another Item</a></center>\n");
} elseif (!empty($_POST['Item_create']) && isset($_SESSION['username']) && ($_SESSION['status'] == 1) && (empty($_POST['NewItem']) )) {
?>
<form name="Item_create" ID="Itemcreate" ACTION="<?php echo $PHP_SELF;?>" METHOD="post" >
<legend>Item Creation</legend>
<fieldset>
<?php
print("<center><H3><font style=color:red;>Try again. Please fill these fields, below.</font></H3></center>");
?>
<?php
print("<center><H3>To create a new Item, fill out the form.</H3></center>");
?>
<table>
<TR>
<TH colspan="1" align="center" valign="top" bgcolor="darkCyan">What is the Item Name?</TH>
<TH colspan="1" align="center" valign="top" bgcolor="darkCyan">Does the Item have an Expiration Date?</TH>
</tr>
<tr>
<TD align="center" valign="middle">
What is the Item Name?
</TD>
<TD align="center" valign="middle">
Is it Perishable?
</TD>
</tr>
<tr>
<TD align="center">
<input type="text" name="NewItem" size="32">
</TD>
<TD align="center">
<input type="checkbox" name="PerishableItem" value="1">
</TD>
</TR>
</table>
<center><INPUT TYPE="submit" NAME="Item_create" ID="Itemcreate" VALUE="Submit" >
</fieldset>
</form>
<?php
}
} elseif (empty($_POST['Item_create']) && isset($_SESSION['username']) && ($_SESSION['status'] == 1) ) { // logged in
?>
<form name="Item_create" ID="Itemcreate" ACTION="<?php echo $PHP_SELF;?>" METHOD="post" >
<legend>Creating an Item</legend>
<fieldset>
<?php
print("<center><H3>To create a new Item, fill out the form.</H3></center>");
?>
<table>
<TR>
<TH colspan="1" align="center" valign="top" bgcolor="darkCyan">What is the Item Name?</TH>
<TH colspan="1" align="center" valign="top" bgcolor="darkCyan">Does the Item have an Expiration Date?</TH>
</tr>
<tr>
<TD align="center" valign="middle">
What is the Item Name?
</TD>
<TD align="center" valign="middle">
Is it Perishable?
</TD>
</tr>
<tr>
<TD align="center">
<input type="text" name="NewItem" size="32">
</TD>
<TD align="center">
<input type="checkbox" name="PerishableItem" value="1">
</TD>
</TR>
</table>
<center><INPUT TYPE="submit" NAME="Item_create" ID="Itemcreate" VALUE="Submit" >
</fieldset>
</form>
<?php
}
?>
<center><INPUT TYPE="button" VALUE="View Items Already Created." onclick= "location = 'created_items.php';" >
<div class="push"></div>
</div>
<? require("inc/footer.inc"); ?>
</body>
</html>