This commit is contained in:
Hamza-Ayed
2026-05-01 02:08:21 +03:00
parent 989f6332f9
commit e68dda58d3
7 changed files with 119 additions and 69 deletions

View File

@@ -1,29 +1,32 @@
<?php
require_once __DIR__ . '/../../connect.php';
$promoCode = filterRequest("promoCode");
$promo_code = filterRequest("promo_code");
$amount = filterRequest("amount");
$description = filterRequest("description");
$passengerID = filterRequest("passengerID"); // يفترض أنه ID وليس قيمة مشفرة
$passengerID = filterRequest("passengerID");
if (empty($promo_code)) {
jsonError("Promo code is required");
exit;
}
$sql = "INSERT INTO `promos`(
`promo_code`, `amount`, `description`, `passengerID`,
`validity_start_date`, `validity_end_date`
)
VALUES (
:promoCode, :amount, :description, :passengerID,
NOW(), DATE_ADD(NOW(), INTERVAL 1 WEEK)
:promo_code, :amount, :description, :passengerID,
NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)
)";
$stmt = $con->prepare($sql);
$stmt->bindValue(':promoCode', $promoCode);
$stmt->bindValue(':promo_code', $promo_code);
$stmt->bindValue(':amount', $amount);
$stmt->bindValue(':description', $description);
$stmt->bindValue(':passengerID', $passengerID);
$stmt->execute();
if ($stmt->rowCount() > 0) {
if ($stmt->execute()) {
jsonSuccess(null, "Promo data saved successfully");
} else {
jsonError("Failed to save promo data");