<?php 
if (isset($_POST['btn-addveh'])) {
    $numplate = trim($_POST['inp_numplate']);
    $make = trim($_POST['inp_make']);
    $model = trim($_POST['inp_model']);
    $engine = trim($_POST['inp_engine']);
    $mileage = trim($_POST['inp_mileage']);
    $year = trim($_POST['inp_year']);
    $color = trim($_POST['inp_color']);
    $bodytype = trim($_POST['inp_bodytype']);
    $doors = trim($_POST['inp_doors']);
    $fueltype = trim($_POST['inp_fueltype']);
    $geartype = trim($_POST['inp_geartype']);
    $price = trim($_POST['inp_price']);
    include_once '../../class_vehicle.php';
    $vehicle = new VEHICLE($MYSQL_HANDLE);
    $result = $MYSQL_HANDLE->query("SELECT `numplate` FROM `vehicles` WHERE `numplate` = '" . $numplate . "'");
    $row = $result->fetch_assoc();
    if ($row['numplate'] == $numplate) {
        echo "ERROR: That vehicle has been registered before!";
    } else {
        $vehicle->addVehicle($numplate, $make, $model, $engine, $mileage, $year, $color, $bodytype, $doors, $fueltype, $geartype, $price);
    }
}
?>
	
	<div class = "container">
		<div class = "form-container">
			<form method = "post" enctype = "multipart/form-data">
				<h2>Register new vehicle</h2>
				<hr/>
<body>

	<?php 
include_once '../../config.php';
include_once '../../class_vehicle.php';
$vehicle = new VEHICLE($MYSQL_HANDLE);
$vehicle->printVehicles();
?>
	
</body>
</html>
	
		<div class = "left">  <label><a href = "https://github.com/Jedrzej94/">github.com</a></label> </div>
		<div class = "right"> <label><a href = "logout.php?logout=true">Logged in as <?php 
print $row['username'];
?>
 (sign out)</a></label> </div>
		
	</div>
</head>

<body>
	
	<div class = "content">
		
		<?php 
$vehicle = new VEHICLE($MYSQL_HANDLE);
if (!isset($_GET['id'])) {
    if (isset($_POST['btn-searchveh'])) {
        $numplate = trim($_POST['inp_numplate']);
        $vehicle->printVehicles($numplate);
        if (isset($_GET['p'])) {
            if ($_GET['p'] == "delstock") {
                $vehicle->deleteVehicle($numplate);
            }
        }
    }
    ?>
				
				<div class = "container">
					<div class = "form-container">
						<form method = "post">