DIDS-Coursework/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addFine.php
rodude123 a6d2a0c17b Created the ability to add fines
Signed-off-by: rodude123 <rodude123@gmail.com>
2022-12-15 23:25:00 +00:00

30 lines
823 B
PHP

<?php
session_start();
require_once 'config.php';
header('Content-Type: application/json');
if (isset($_SESSION["username"]) && isset($_SESSION["admin"]))
{
$conn = dbConn();
$amount = $_POST["amount"];
$points = $_POST["points"];
$incident = $_POST["incident"];
$stmt = $conn->prepare("INSERT INTO Fines (Fine_amount, Fine_points, Incident_ID) VALUES (:amount, :points, :incident)");
$stmt->bindParam(":amount", $amount);
$stmt->bindParam(":points", $points);
$stmt->bindParam(":incident", $incident);
$stmt->execute();
echo json_encode(array("message" => "ok"));
}
else if (isset($_SESSION["username"]) && !isset($_SESSION["admin"]))
{
echo json_encode(array("message" => "not logged in as admin"));
}
else
{
echo json_encode(array("message" => "Not logged in "));
}
{
}