This repository has been archived by the owner on Jan 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_products_edit.php
83 lines (73 loc) · 2.36 KB
/
manage_products_edit.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
<?php
require_once 'sys/functions/general.php';
require_once 'sys/functions/fetchers.php';
returnHeader("Produkt bearbeiten");
checkUserIsOnline();
$id = $_GET['id'];
$product = fetch_product($id);
if(empty($id)){
?>
<div class="box error">
Es muss eine Produkt-ID angegeben werden.
</div>
<?php
}else if($product['user_id'] == $_SESSION['user_id'] || $_SESSION['user_isAdmin']){
?>
<form action="manage_products_edit_send.php" method="post" enctype="multipart/form-data">
<input type="hidden" value="<?php echo $id ?>" name="id"/>
Name: <input type="text" name="name" value="<?php echo $product['name'] ?>" required="required"/><br><br>
Beschreibung: <input type="text" name="description" value="<?php echo $product['description'] ?>" required="required"/><br><br>
Kategorie:
<select name="cat">
<option>Kategorie auswählen</option>
<?php
$cats = fetch_categories();
$checked_cats = array($product['cat_id']);
foreach ($cats as $this_cat) {
echo '<option value="' . $this_cat['id'] . '"' . (in_array($this_cat['id'], $checked_cats) ? ' selected="selected"' : '') . '>' . $this_cat['name'] . '</option>';
}
?>
</select><br><br>
<?php
if($_SESSION['user_isAdmin']){
?>
Benutzer:
<select name="user">
<option>Benutzer auswählen</option>
<?php
$users = fetch_users();
$checked_users = array($product['user_id']);
foreach ($users as $this_users) {
echo '<option value="' . $this_users['id'] . '"' . (in_array($this_users['id'], $checked_users) ? ' selected="selected"' : '') . '>' . $this_users['name'] . '</option>';
}
?>
</select><br><br>
<?php
}
?>
Preis (in Euro): <input type="number" name="price" value="<?php echo $product['price'] ?>" required="required"/><br><br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Bild:
<ul class="productlist">
<li class="need-clearfix">
<div class="prod_imgbox">
<img src="sys/img/products/<?php echo $product['id'] ?>.png">
</div>
</li>
<div>
<input type="file" name="image" placeholder="Bild" id="image" accept=".png">
</div>
</ul>
<input type="reset">
<input type="submit">
</form>
<?php
}else{
?>
<div class="box error">
Du kannst keine fremden Produkte bearbeiten.
</div>
<?php
}
returnFooter();
?>