You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
FutureCraft/approve_donation.php

32 lines
852 B

<?php
require 'db_connection.php';
session_start();
// Check if the admin is logged in
if (!isset($_SESSION['user_email']) || $_SESSION['role'] !== 'admin') {
header("Location: login.php");
exit;
}
// Check if the donation ID is provided
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$donation_id = $_GET['id'];
// Update the donation status to 'approved'
$stmt = $conn->prepare("UPDATE material_donations SET status = 'approved' WHERE id = ?");
$stmt->bind_param("i", $donation_id);
if ($stmt->execute()) {
$_SESSION['success_message'] = "Donation approved successfully.";
} else {
$_SESSION['error_message'] = "Failed to approve the donation.";
}
$stmt->close();
} else {
$_SESSION['error_message'] = "Invalid donation ID.";
}
header("Location: admin_dashboard.php");
exit;
?>