-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
94 lines (88 loc) · 3.11 KB
/
Copy pathcreate.php
File metadata and controls
94 lines (88 loc) · 3.11 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
<!--
Jimmy Silva, 4/4/2024, IT202-006, Web Project Phase 4 jns@njit.edu
-->
<?php
require_once('database_njit.php');
// check var
//check session now
require_once('check_login.php');
$db = getDB();
if( !isset($toyCode)) { $toyCode = ''; }
if( !isset($toyName)) { $toyName = ''; }
if( !isset($description)) { $description = ''; }
if( !isset($price)) { $price = ''; }
if( !isset($toyCategory)) { $toyCategory = ''; }
//get cate
$toyCategory_ID = filter_input(INPUT_GET, 'toy_category_id', FILTER_VALIDATE_INT);
if ($toyCategory_ID == NULL || $toyCategory_ID == FALSE) {
$toyCategory_ID = 1;
}
// Get name for selected category
$queryToyCategory = 'SELECT * FROM toyCategories WHERE toyCategoryID = :toy_category_id';
$statement1 = $db->prepare($queryToyCategory);
$statement1->bindValue(':toy_category_id', $toyCategory_ID);
$statement1->execute();
$category = $statement1->fetch();
$category_name = $category['toyCategoryName'];
$statement1->closeCursor();
// Get all categories
$queryAllCategories = 'SELECT * FROM toyCategories ORDER BY toyCategoryID';
$statement2 = $db->prepare($queryAllCategories);
$statement2->execute();
$categories = $statement2->fetchAll();
$statement2->closeCursor();
//echo print_r($toyCode);
?>
<html>
<head>
<title>Blockitic Inc</title>
<!-- link to stylesheet -->
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<?php include 'header.php' ?>
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js"
integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8="
crossorigin="anonymous"></script>
<script src ="create.js"></script>
<h3>Create a New Toy in Database</h3>
<?php
if( !empty($error_m) ) {
echo "<p>";
echo $error_m;
echo "</p>";
}
?>
<form action="create_auth.php" method='post' id="createForm">
<label for="toyCategories">Choose a category:</label>
<select name="toyCategory">
<?php foreach($categories as $category) : ?>
<option value="<?php echo $category['toyCategoryID']; ?>">
<?php echo $category['toyCategoryName']; ?></option>
<?php endforeach; ?>
</select>
<br>
<label>Toy Code: </label>
<input type="text" name="toyCode" id="toyCode" value=""/>
<span>*</span>
<br>
<label>Toy Name: </label>
<input type='text' name="toyName" id="toyName" value = ""/>
<span>*</span>
<br>
<p><label>Toy Description:</label></p>
<textarea name="description" rows="4" cols="50" id="description" value=""></textarea>
<span>*</span>
<br>
<label>Toy Price: </label>
<input type='text' name='price' id="price" value=''/>
<span>*</span>
<br>
<input type="submit" value="Submit" id="submit_button">
<input type="reset" value="Clear Form" id="reset_button">
</form>
<br>
<br>
<?php include 'footer.php' ?>
</body>
</html>