diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php new file mode 100644 index 0000000..3114169 --- /dev/null +++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/addVehicle.php @@ -0,0 +1,41 @@ +prepare("INSERT INTO Vehicle (Vehicle_type, Vehicle_colour, Vehicle_licence) VALUES (:type, :colour, :plateNum)"); + $stmt->bindParam(":type", $_POST["type"]); + $stmt->bindParam(":colour", $_POST["colour"]); + $stmt->bindParam(":plateNum", $_POST["plateNum"]); + $stmt->execute(); + $vehicleID = $conn->lastInsertId(); + if (isset($_POST["name"]) && isset($_POST["address"]) && isset($_POST["licence"])) + { + $stmtPeople = $conn->prepare("INSERT INTO People (People_name, People_address, People_licence) VALUES (:name, :address, :licence)"); + $stmtPeople->bindParam(":name", $_POST["name"]); + $stmtPeople->bindParam(":address", $_POST["address"]); + $stmtPeople->bindParam(":licence", $_POST["licence"]); + $stmtPeople->execute(); + $peopleID = $conn->lastInsertId(); + + $stmtOwner = $conn->prepare("INSERT INTO Ownership (Vehicle_ID, People_ID) VALUES (:vehicleID, :peopleID)"); + $stmtOwner->bindParam(":vehicleID", $vehicleID); + $stmtOwner->bindParam(":peopleID", $peopleID); + $stmtOwner->execute(); + echo json_encode(array("message" => "Vehicle and new owner added successfully")); + } + else + { + $stmt = $conn->prepare("INSERT INTO Ownership (Vehicle_ID, People_ID) VALUES (:vehicleID, :peopleID)"); + $stmt->bindParam(":vehicleID", $vehicleID); + $stmt->bindParam(":peopleID", $_POST["peopleID"]); + $stmt->execute(); + echo json_encode(array("message" => "Vehicle added successfully and assigned to existing owner")); + } +} +else +{ + echo json_encode(array("message" => "Not logged in")); +} \ No newline at end of file diff --git a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html index 6bf547d..c7d2fa2 100644 --- a/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html +++ b/DIS-COMP4039-CW2-psxrp11-20450011/psxrp11-20450011_InstallationFiles/changePassword.html @@ -6,33 +6,40 @@
- + -