Initial commit with updated Auth and media ignored
This commit is contained in:
45
ride/kazan/add.php
Executable file
45
ride/kazan/add.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$kazan = filterRequest("kazan");
|
||||
$adminId = filterRequest("adminId");
|
||||
$latePrice = filterRequest("latePrice");
|
||||
$heavyPrice = filterRequest("heavyPrice");
|
||||
$naturePrice = filterRequest("naturePrice");
|
||||
$comfortPrice = filterRequest("comfortPrice");
|
||||
$speedPrice = filterRequest("speedPrice");
|
||||
$deliveryPrice = filterRequest("deliveryPrice");
|
||||
$freePrice = filterRequest("freePrice");
|
||||
$country = filterRequest("country");
|
||||
$fuelPrice = filterRequest("fuelPrice");
|
||||
|
||||
// Prepare an SQL statement with placeholders for the values
|
||||
$sql = "INSERT INTO `kazan`( `country`,`kazan`, `comfortPrice`, `speedPrice`, `deliveryPrice`, `freePrice`, `latePrice`, `heavyPrice`, `adminId`, `naturePrice`, `fuelPrice`) VALUES (:country,:kazan, :comfortPrice, :speedPrice, :deliveryPrice, :freePrice, :latePrice, :heavyPrice, :adminId, :naturePrice,:fuelPrice)";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
|
||||
// Bind the parameters to the SQL query
|
||||
$stmt->bindParam(':kazan', $kazan);
|
||||
$stmt->bindParam(':comfortPrice', $comfortPrice);
|
||||
$stmt->bindParam(':speedPrice', $speedPrice);
|
||||
$stmt->bindParam(':deliveryPrice', $deliveryPrice);
|
||||
$stmt->bindParam(':freePrice', $freePrice);
|
||||
$stmt->bindParam(':latePrice', $latePrice);
|
||||
$stmt->bindParam(':heavyPrice', $heavyPrice);
|
||||
$stmt->bindParam(':adminId', $adminId);
|
||||
$stmt->bindParam(':naturePrice', $naturePrice);
|
||||
$stmt->bindParam(':country', $country);
|
||||
$stmt->bindParam(':fuelPrice', $fuelPrice);
|
||||
|
||||
// Execute the statement
|
||||
if ($stmt->execute()) {
|
||||
// Print a success message
|
||||
jsonSuccess(null, "Kazan saved successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
jsonError("Failed to save Kazan");
|
||||
}
|
||||
|
||||
// Close the statement
|
||||
$stmt->close();
|
||||
?>
|
||||
0
ride/kazan/delete.php
Normal file
0
ride/kazan/delete.php
Normal file
0
ride/kazan/error_log
Normal file
0
ride/kazan/error_log
Normal file
18
ride/kazan/get.php
Normal file
18
ride/kazan/get.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$country = filterRequest("country");
|
||||
|
||||
$sql = "SELECT * FROM `kazan` WHERE `country` = :country";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':country', $country, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
jsonSuccess($row);
|
||||
} else {
|
||||
jsonError("No Kazan record found");
|
||||
}
|
||||
?>
|
||||
38
ride/kazan/update.php
Normal file
38
ride/kazan/update.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$allowedFields = [
|
||||
"kazan", "comfortPrice", "speedPrice", "deliveryPrice",
|
||||
"freePrice", "latePrice", "heavyPrice", "adminId", "createdAt", "naturePrice"
|
||||
];
|
||||
|
||||
$setParts = [];
|
||||
$params = [];
|
||||
|
||||
foreach ($allowedFields as $field) {
|
||||
if (isset($_POST[$field])) {
|
||||
$value = filterRequest($field);
|
||||
$setParts[] = "`$field` = :$field";
|
||||
$params[":$field"] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($setParts)) {
|
||||
jsonError("No valid fields to update.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE `kazan` SET " . implode(", ", $setParts) . " WHERE `id` = :id";
|
||||
$params[":id"] = $id;
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Kazan data updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update kazan data");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user