-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath_to_your_php_script.php
More file actions
33 lines (29 loc) · 991 Bytes
/
path_to_your_php_script.php
File metadata and controls
33 lines (29 loc) · 991 Bytes
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
<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$errors = [];
// Validate Quantity
if (empty($_POST['quantity'])) {
$errors[] = "Please select a quantity.";
}
// Validate Size (at least one size should be selected)
if (empty($_POST['size'])) {
$errors[] = "Please select at least one size.";
}
// Validate Option (Egg or Eggless should be selected)
if (empty($_POST['option'])) {
$errors[] = "Please select an option (Egg or Eggless).";
}
// If there are no errors, process the data (example: add to cart, redirect, etc.)
if (empty($errors)) {
// Process the form data, e.g., redirect to checkout or save to database
header("Location: checkout.php"); // Example: Redirect to checkout page
exit;
} else {
// Display errors if any
foreach ($errors as $error) {
echo "<p style='color: red;'>$error</p>";
}
}
}
?>