<!DOCTYPE html>

<!--
	Owner's profile page.
	
	Author: 		Philip Lim
	Student I.D.: 	7485506
-->

<?php 
session_start();
include "php/support.php";
if (!loggedIn()) {
    header("Location: http://localhost/apartmentRenting/login.php");
} elseif (getTypeOfAccount($_SESSION['user_id']) != '1') {
    header("Location: http://localhost/apartmentRenting/profileHome.php");
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        addNewApartment($_SESSION['user_id']);
        header("Location: http://localhost/apartmentRenting/profileHome.php");
    }
}
?>

<html>
	<head>
		<title>Add new apartment</title>
		<meta name="Author" content="Philip Lim"/>
		<meta name="Keywords" content=""/>
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="http://localhost/apartmentRenting/css/apartmentRenting.css"/>
<!DOCTYPE html>

<!--
	Tenant's profile page.
	
	Author: 		Philip Lim
	Student I.D.: 	7485506
-->

<?php 
session_start();
include 'php/support.php';
// If the user is not logged in, redirect to login page.
if (!loggedIn()) {
    header("Location: http://localhost/apartmentRenting/login.php");
} elseif (getTypeOfAccount($_SESSION['user_id']) == '0') {
    // If it was submitted, update profile.
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        updateTenantProfile($_SESSION['user_id']);
        header("Location: http://localhost/apartmentRenting/profileHome.php");
    } else {
        // Connect to database
        $connection = mysqli_connect("localhost", "root", "", "rental_27485506");
        if (mysqli_connect_errno()) {
            print "Connection failed: " . mysqli_connect_error();
            exit;
        }
        // Access user's information
        $user_id = $_SESSION['user_id'];
        $query = "SELECT * from `tenantsprofiles` WHERE `user_id`='{$user_id}'";
        $result = mysqli_query($connection, $query);