require_once 'garageTableGateway.php'; //connect to garagetable require_once 'busTableGateway.php'; //connect to bus tbale //if (!isset($_GET['id'])) { // die("Halt"); //} $id = $_GET['id']; //id has to be valid $connection = Connection::getInstance(); //conenct to the db $garageGateway = new garageTableGateway($connection); //for conenction to garage table $busGateway = new busTableGateway($connection); //for connection to bus table $garages = $garageGateway->getGarageById($id); //get garagebyid form garages $bus = $busGateway->getBusByGarageId($id); //get busbygarageid from bus //the garage selected will show all buses that is stored by that garage //$row = $statement->fetch(PDO::FETCH_ASSOC); //if (!$row) { // die("Unable to get Garage By ID"); //} ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8">
require_once 'validateGarage.php'; require_once 'loginhelper.php'; start_session(); //if user is not logged in, return to log in form if (!is_logged_in()) { header("Location: loginform.php"); } $user = $_SESSION['user']; if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!isset($_GET['id'])) { die("Illegal Request"); } $id = $_GET['id']; $dbconnection = dbconnection::getConnection(); $gateway = new garageTableGateway($dbconnection); $statement = $gateway->getGarageById($id); $row = $statement->fetch(PDO::FETCH_ASSOC); if (!$row) { die("Illegal Request"); } } else { if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!isset($_POST['id'])) { die("Illegal request"); } $id = $_POST['id']; $row = $formdata; } else { die("Illegal request"); } }