-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoffeeAdd.php
99 lines (77 loc) · 2.86 KB
/
CoffeeAdd.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
<?php
require './Controller/CoffeeController.php';
$coffeeController = new CoffeeController();
$title = "Add a new Coffee";
if(isset($_GET["update"]))
{
$coffee = $coffeeController->GetCoffeeById($_GET["update"]);
$content ="<form action='' method='post'>
<fieldset>
<legend>Add a new Coffee</legend>
<label for='name'>Name: </label>
<input type='text' class='inputField' name='txtName' value='$coffee->name' /><br/>
<label for='type'>Type: </label>
<select class='inputField' name='ddlType'>
<option value='%'>All</option>"
.$coffeeController->CreateOptionValues($coffeeController->GetCoffeeTypes()).
"</select><br/>
<label for='price'>Price: </label>
<input type='text' class='inputField' name='txtPrice' value='$coffee->price'/><br/>
<label for='roast'>Roast: </label>
<input type='text' class='inputField' name='txtRoast' value='$coffee->roast' /><br/>
<label for='country'>Country: </label>
<input type='text' class='inputField' name='txtCountry' value='$coffee->country' /><br/>
<label for='image'>Image: </label>
<select class='inputField' name='ddlImage'>"
.$coffeeController->GetImages().
"</select></br>
<label for='review'>Review: </label>
<textarea cols='70' rows='12' name='txtReview'>$coffee->review</textarea></br>
<input type='submit' value='Submit'>
</fieldset>
</form>";
}
else
{
$content ="<form action='' method='post'>
<fieldset>
<legend>Add a new Coffee</legend>
<label for='name'>Name: </label>
<input type='text' class='inputField' name='txtName' /><br/>
<label for='type'>Type: </label>
<select class='inputField' name='ddlType'>
<option value='%'>All</option>"
.$coffeeController->CreateOptionValues($coffeeController->GetCoffeeTypes()).
"</select><br/>
<label for='price'>Price: </label>
<input type='text' class='inputField' name='txtPrice' /><br/>
<label for='roast'>Roast: </label>
<input type='text' class='inputField' name='txtRoast' /><br/>
<label for='country'>Country: </label>
<input type='text' class='inputField' name='txtCountry' /><br/>
<label for='image'>Image: </label>
<select class='inputField' name='ddlImage'>"
.$coffeeController->GetImages().
"</select></br>
<label for='review'>Review: </label>
<textarea cols='70' rows='12' name='txtReview'></textarea></br>
<input type='submit' value='Submit'>
</fieldset>
</form>";
}
if(isset($_GET["update"]))
{
if(isset($_POST["txtName"]))
{
$coffeeController->UpdateCoffee($_GET["update"]);
}
}
else
{
if(isset($_POST["txtName"]))
{
$coffeeController->InsertCoffee();
}
}
include './Template.php';
?>