-
Notifications
You must be signed in to change notification settings - Fork 0
/
approval.php
126 lines (109 loc) · 3.35 KB
/
approval.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
115
116
117
118
119
120
121
122
123
124
125
126
<?php
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "drinkityasin";
// Create a connection to the database
$conn = new mysqli($servername, $username, $password, $dbname);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if the form for accepting or rejecting recipes has been submitted
if (isset($_POST['accept']) || isset($_POST['reject'])) {
// Handle form submission here
// You can access the ID of the recipe to accept or reject using $_POST['recipe_id']
if (isset($_POST['accept'])) {
// Code to accept the recipe (set 'hyvaksytty' to 1)
} elseif (isset($_POST['reject'])) {
// Code to reject the recipe (delete it from the database)
}
// Redirect back to the same page or any other appropriate page
header("Location: hyvaksy.php");
exit();
}
// Retrieve all recipes with 'hyvaksytty' set to 0 from the database
$selectQuery = "SELECT * FROM drinks WHERE hyvaksytty = 0";
$result = $conn->query($selectQuery);
// Close the database connection
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>Accept or Reject Recipes</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
}
table {
border-collapse: collapse;
width: 80%;
margin: 0 auto;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.accept-button, .reject-button {
padding: 5px 10px;
margin: 2px;
cursor: pointer;
}
.accept-button {
background-color: #4CAF50;
color: white;
}
.reject-button {
background-color: #f44336;
color: white;
}
</style>
</head>
<body>
<h1>Accept or Reject Recipes</h1>
<!-- Display a table of recipes to accept or reject -->
<table>
<thead>
<tr>
<th>Name</th>
<th>Category</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['category'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>";
echo "<form action='hyvaksy.php' method='post'>";
echo "<input type='hidden' name='recipe_id' value='" . $row['drink_id'] . "'>";
echo "<button type='submit' name='accept' class='accept-button'>Accept</button>";
echo "<button type='submit' name='reject' class='reject-button'>Reject</button>";
echo "</form>";
echo "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='4'>No recipes to display.</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>