<?php
require_once("../includes/initialize.php");
//if ($session->is_logged_in()){redirect_to("../dashboard.php");}
$message="";

$username="";
$password="";
$surname="";
$othernames="";
$email="";
$upload="";
$errors = array();

if (isset($_POST['submit'])){
	
$username = mysql_real_escape_string($_POST['username']);	
$password =  mysql_real_escape_string($_POST['password']);
$surname = mysql_real_escape_string($_POST['surname']);	
$othernames =  mysql_real_escape_string($_POST['othernames']);

//echo "Done";
if (empty($email)){
	array_push($errors, "Username is required");
}if (empty($password)){
	array_push($errors, "Password is required");
}
if (count($errors)== 0){
$found_user = ADMINACCOUNT::authenticate($username, $password);

if ($found_user){ 
	
	$session->login($found_user);
	
	
	redirect_to("dashboard.php");
}else {
$message="Form no/email address combination incorrect";	
	}
}
}

 ?>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OSCOTECHADMIN:index</title>
<link href="../stylesheet/newuser.css" type="text/css" rel="stylesheet" />
</head>

<body>
<div class="setimage">
<img src="images/icon.png" />

</div>
<div class="header">
<h2>Account Details</h2>
</div>
<form method="post" class="formup" action="account_updata.php">
<?php if (count($errors)>0){?>
<div class="error">

<?php foreach ($errors as $error){?>
<p><?php echo $error; ?></p>
<?php } ?>

</div>
<?php }?>	
<?php if ($message !=''){
	 echo output_message($message);
}?>

<div class="input-group">

<label>Email</label>
<input type="email" name="email" style="margin-left:43px" value="<?php echo htmlentities($email);?>" />

</div>
<div id="input-group2">
<label>Password</label>
<input type="password" name="password" style="margin-left:20px" value="<?php echo htmlentities($password)?>";/>
</div>

<div class="input-group">

<label>Surname</label>
<input type="text" name="surname" style="margin-left:20px" value="<?php echo htmlentities($surname);?>" />

</div>
<div id="input-group2">
<label>Othernames</label>
<input type="othernames" name="othernames" value="<?php echo htmlentities($othernames)?>";/>
</div>

<div id="input-group2">
<label>Passport</label>
<input type="file" style="margin-left:20px" name="upload" value="";/>
</div>

<div class="input-group2">
<center><button type="submit" name="submit" style="width:30%; font-stretch:extra-expanded; font-weight:bolder" class="btn">Update</button></center>
</div>
</form>
</body>
</html>