Initial commit with updated Auth and media ignored
This commit is contained in:
29
ride/promo/get.php
Normal file
29
ride/promo/get.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$promo_code = filterRequest("promo_code");
|
||||
|
||||
$sql = "SELECT
|
||||
`id`,
|
||||
`promo_code`,
|
||||
`amount`,
|
||||
`description`,
|
||||
`validity_start_date`,
|
||||
`validity_end_date`
|
||||
FROM
|
||||
`promos`
|
||||
WHERE
|
||||
`promo_code` = :promo_code
|
||||
AND CURDATE() BETWEEN validity_start_date AND validity_end_date";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':promo_code', $promo_code, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) {
|
||||
jsonSuccess($result);
|
||||
} else {
|
||||
jsonError("Failed to retrieve promo records");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user