BLACKSITE
:
216.73.217.4
:
104.37.75.190 / alpenpass.ca
:
Linux server3.pointsplan.com 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
:
/
home2
/
apca
/
www
/
admin
/
Upload File:
files >> //home2/apca/www/admin/process_coupon.php
<?php session_start(); include('../includes/config.php'); // Database connection if ($_SERVER["REQUEST_METHOD"] === "POST") { $name = $_POST['name']; $coupon_code = $_POST['coupon_code']; $description = $_POST['description']; $terms = $_POST['terms']; $categories = isset($_POST['categories']) ? implode(',', $_POST['categories']) : ''; $discount_type = $_POST['discount_type']; $discount_value = $_POST['discount_value']; $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; $status = $_POST['status']; $created_by = $_SESSION['admin_user'] ?? 'Unknown'; // Track who created it // **INSERT NEW COUPON** if (empty($_POST['id'])) { $stmt = $dbh->prepare("INSERT INTO coupons (name, coupon_code, description, terms, categories, discount_type, discount_value, start_date, end_date, status, created_by, created_at) VALUES (:name, :coupon_code, :description, :terms, :categories, :discount_type, :discount_value, :start_date, :end_date, :status, :created_by, NOW())"); } else { // **UPDATE EXISTING COUPON** $stmt = $dbh->prepare("UPDATE coupons SET name=:name, coupon_code=:coupon_code, description=:description, terms=:terms, categories=:categories, discount_type=:discount_type, discount_value=:discount_value, start_date=:start_date, end_date=:end_date, status=:status WHERE id=:id"); $stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT); } // Bind parameters $stmt->bindParam(':name', $name); $stmt->bindParam(':coupon_code', $coupon_code); $stmt->bindParam(':description', $description); $stmt->bindParam(':terms', $terms); $stmt->bindParam(':categories', $categories); $stmt->bindParam(':discount_type', $discount_type); $stmt->bindParam(':discount_value', $discount_value); $stmt->bindParam(':start_date', $start_date); $stmt->bindParam(':end_date', $end_date); $stmt->bindParam(':status', $status); $stmt->bindParam(':created_by', $created_by); if ($stmt->execute()) { $_SESSION['success_message'] = "Coupon saved successfully!"; } else { $_SESSION['error_message'] = "Error saving coupon."; } header("Location: admin_coupons.php"); exit(); } // **DELETE COUPON** if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { $stmt = $dbh->prepare("DELETE FROM coupons WHERE id = ?"); if ($stmt->execute([$_GET['delete']])) { $_SESSION['success_message'] = "Coupon deleted successfully!"; } else { $_SESSION['error_message'] = "Error deleting coupon."; } header("Location: admin_coupons.php"); exit(); } ?>