first commit
This commit is contained in:
34
backend/ride/promo/add.php
Executable file
34
backend/ride/promo/add.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?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");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user