<?php

require_once 'header.php';
$controller = new ControllerPropertyType();
if (isset($_POST['submit'])) {
    $propertytype_found = $controller->getPropertyTypeByPropertyType(trim($_POST['property_type']));
    if ($propertytype_found == null) {
        $itm = new PropertyType();
        $itm->property_type = htmlspecialchars(trim(strip_tags($_POST['property_type'])), ENT_QUOTES);
        $itm->created_at = time();
        $itm->updated_at = time();
        $controller->insertPropertyType($itm);
        echo "<script type='text/javascript'>location.href='propertytypes.php';</script>";
    } else {
        echo "<script>alert('Property Type exist already.');</script>";
    }
}
?>


<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="http://getbootstrap.com/assets/ico/favicon.ico">

    <title>RealEstate Finder</title>