-
Notifications
You must be signed in to change notification settings - Fork 0
/
soups.php
114 lines (96 loc) · 2.57 KB
/
soups.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
<html>
<head><title>Soups update</title></head>
<body>
<form action="home3.php" method="get">
<input type="submit" name="back" value="Home">
</form>
</body>
<?php
include('db.php');
if(isset($_POST['save']))
{
$image_description=$_POST['description'];
$cost=$_POST['cost'];
//$variety=$_POST['variety'];
$image=$_FILES['file']['name'];
$image_size =$_FILES['file']['size'];
$image_type =$_FILES['file']['type'];
if($image_type =='image/jpeg' || $image_type == 'image/gif' || $image_type =='image/png')
{
//move image to folder
$uploadfile = move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
//insert to database
$query= mysql_query("INSERT INTO menu_soups(item,name,size,cost,variety) values('$image','$image_description','$image_size','$cost','Soups')");
if($uploadfile && $query)
{
echo "<script>
alert('Item Uploaded Successfully');
</script>";
}
else if(!$uploadfile)
{
echo "<script>
alert('Uploading Problem');
</script>";}
else if(!$query)
{echo "<script>
alert('Item not Saved');
</script>";
}
}
else
{
echo"Invalid File Type";
}
}
?>
<html>
<head>
<title>Upload Image</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
Item Name :
<input type="text" name="description">
Item Cost :
<input type="text" name="cost">
Variety :
<input type="text" name="variety" value="Soups" disabled>
File:
<input type="file" name="file">
<input type="submit" value="Upload Picture" name="save">
</form>
<table>
<thead>
<tr>
<th>ID</th>
<th>Item</th>
<th>File name</th>
<th>Item Name</th>
<th>Size</th>
<th>Cost</th>
<th>Variety</th>
</tr>
</thead>
<tbody>
<?php
$query=mysql_query ("select * from menu_soups");
$i=1;
while($row=mysql_fetch_object($query))
{
?>
<tr>
<td><?php echo $i;$i++?></td>
<td><img style="width:200px;height:200px;"src="<?php echo'upload/'.$row->item ?>"></td>
<td><?php echo $row->item?></td>
<td><?php echo $row->name ?></td>
<td><?php echo $row->size ?></td>
<td><?php echo $row->cost ?></td>
<td><?php echo $row->variety ?></td>
</tr>
<?php } ?>
</table>
<form name="index" method="GET">
<input type="text" name="idd" value="<?php echo $row->id ?>" action="delete.php" hidden >
</body>
</html>