<?Php
/*
* @author Istvan Franko
* @copyright 2014
*/
ob_start();
session_start();

if (!isset($_SESSION['cart'])) 
{
  $_SESSION['cart']=array(); 
}

if (!isset($_SESSION['loggedin'])) 
{
  $_SESSION['loggedin'] = '0'; 
}
?>

<html>

<head>
<title>Natty Notebooks Inc.</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>

<body>

<div id="container">

	<div id="header">
	<! header picture in css >
	</div>
	
	<div id="navigation">
		<?php include 'navigation-bar.php'; ?>
	</div>
	
<div id="aside">
	<!--Link for navigation-->
	<a href="product-list.php"><p style="text-align:center">Back to list</a></p>	

	<fieldset style="width:85%"><legend>HELP</legend>
	<p>You can log-out here or navigate to password change and review your order history.</p> 
	</fieldset><br>
</div>


<div id="content">

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
unset($_SESSION['loggedin']);
header('Location: index.php');
}

$con = mysql_connect("localhost","*****","*****");
if (!$con)
{
	die('Could not connect: ' . mysql_error());
}


mysql_select_db("university", $con);

//get user details from database
$userid = $_SESSION['loggedin'];
$result = mysql_query("SELECT * FROM users WHERE UserID='$userid'");
while ($row = mysql_fetch_array($result))
{
$FullName=$row['FullName'];
$Email=$row['Email'];
$Phone=$row['Phone'];
}
?>

	<!--Log-out button-->
	<form  method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
	<input type="submit" style="float: right;" value="Logout">
	</form>
<br>
<fieldset style="width:70%"><legend>YOUR ACCOUNT</legend>

<?php

if ($_SESSION['loggedin'] > 0)
	{
	echo "<p><br>Your details<br>";
	echo "============" . "<br><br>";
	echo "Your name is: " . $FullName . "<br><br>";
	echo "Your email address is: " . $Email . "<br><br>";
	echo "Your phone number is: " . $Phone . "<br><br><hr/></p>";

	//Change your password
	echo "<p><a href='password-change.php'><p style='text-align:center'>Change your password</a></p>";	

	//Your order history
	echo "<p><a href='order-list.php'><p style='text-align:center'>Your order history</a></p>";
	}
	else 
	{
	echo "<h2>You are not logged in!!!</h2>";
	}
ob_end_flush();
?>

</fieldset>
<br>

</div>

<div id="footer">
<p align="center">Copyright &#169; Istvan Franko, 2014</p>
</div>
	

</div>
</body>
</html>