31 lines
954 B
PHP
Executable File
31 lines
954 B
PHP
Executable File
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$promoCode = filterRequest("promoCode");
|
|
$amount = filterRequest("amount");
|
|
$description = filterRequest("description");
|
|
$passengerID = filterRequest("passengerID"); // يفترض أنه ID وليس قيمة مشفرة
|
|
|
|
$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)
|
|
)";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->bindValue(':promoCode', $promoCode);
|
|
$stmt->bindValue(':amount', $amount);
|
|
$stmt->bindValue(':description', $description);
|
|
$stmt->bindValue(':passengerID', $passengerID);
|
|
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
jsonSuccess(null, "Promo data saved successfully");
|
|
} else {
|
|
jsonError("Failed to save promo data");
|
|
}
|
|
?>
|