34 lines
962 B
PHP
34 lines
962 B
PHP
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$promo_code = filterRequest("promo_code");
|
|
$amount = filterRequest("amount");
|
|
$description = filterRequest("description");
|
|
$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 (
|
|
:promo_code, :amount, :description, :passengerID,
|
|
NOW(), DATE_ADD(NOW(), INTERVAL 1 MONTH)
|
|
)";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->bindValue(':promo_code', $promo_code);
|
|
$stmt->bindValue(':amount', $amount);
|
|
$stmt->bindValue(':description', $description);
|
|
$stmt->bindValue(':passengerID', $passengerID);
|
|
|
|
if ($stmt->execute()) {
|
|
jsonSuccess(null, "Promo data saved successfully");
|
|
} else {
|
|
jsonError("Failed to save promo data");
|
|
}
|
|
?>
|