prepare("SELECT id FROM restaurants WHERE user_id = ?");
$stmt->execute([$owner_id]);
$restaurant = $stmt->fetch();
if (!$restaurant) {
echo "
You are not associated with any restaurant.
";
include 'footer.php';
exit;
}
$restaurant_id = $restaurant['id'];
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? '';
$cuisine = $_POST['cuisine'] ?? '';
$address = $_POST['address'] ?? '';
$phone_number = $_POST['phone_number'] ?? '';
$image_url = $_POST['image_url'] ?? '';
if ($name && $cuisine && $address) {
$update_stmt = $pdo->prepare("UPDATE restaurants SET name = ?, cuisine = ?, address = ?, phone_number = ?, image_url = ? WHERE id = ? AND user_id = ?");
$update_stmt->execute([$name, $cuisine, $address, $phone_number, $image_url, $restaurant_id, $owner_id]);
// Redirect to the dashboard with a success message
$_SESSION['success_message'] = "Your restaurant details have been updated successfully!";
header('Location: index.php');
exit;
} else {
$error = "Name, Cuisine, and Address are required fields.";
}
}
// Fetch current restaurant details
$stmt = $pdo->prepare("SELECT * FROM restaurants WHERE id = ?");
$stmt->execute([$restaurant_id]);
$restaurant_details = $stmt->fetch();
?>
Edit Your Restaurant Details