Files
Siro/walletintaleq.intaleq.xyz/v2/main/ride/tips/add.php
2026-06-11 18:22:59 +03:00

37 lines
1.1 KiB
PHP
Executable File

<?php
include "../../connect.php";
$passengerID = filterRequest("passengerID");
$driverID = filterRequest("driverID");
$rideID = filterRequest("rideID");
$tipAmount = filterRequest("tipAmount");
// Validate tipAmount to ensure it fits within the column's allowed range
if (!is_numeric($tipAmount) || $tipAmount < 0 || $tipAmount > 99999999.99) {
printFailure("Invalid tip amount.");
exit();
}
// Assuming your `created_at` column is of type TIMESTAMP and has the default value CURRENT_TIMESTAMP
$sql = "INSERT INTO `tips`(`id`, `driverID`, `passengerID`, `rideID`, `tipAmount`) VALUES (null, :driverID, :passengerID, :rideID, :tipAmount)";
$stmt = $con->prepare($sql);
// Bind parameters to prevent SQL injection
$stmt->bindParam(':driverID', $driverID);
$stmt->bindParam(':passengerID', $passengerID);
$stmt->bindParam(':rideID', $rideID);
$stmt->bindParam(':tipAmount', $tipAmount);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = 'Tip inserted successfully');
} else {
// Print a failure message
printFailure($message = "Failed to save tip information");
}
?>