<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<?php 
  require '../data/conf.php'; 
  require '../data/func.php';
      ?>
<html>
<head>
<title><?=$site_name; ?></title>
<link href="../themes/grey/grey.css" title="compact" rel="stylesheet" type="text/css">
</head><body>
	<div id="frame">
	<div id="contentheader"><h1><a href="."><?=$site_name; ?></a>: <?=$tagline; ?></h1></div>
	<div id="contentleft">
	<h1>Info</h1>
		<p>Please enter your desired username and password for the admin area. Note: The password must be longer than 6 characters.</p>
	</div>

<?php

	if (isset($_POST['submitBtn'])){
		// Get user input
		$username  = isset($_POST['username']) ? $_POST['username'] : '';
		$password1 = isset($_POST['password1']) ? $_POST['password1'] : '';
		$password2 = isset($_POST['password2']) ? $_POST['password2'] : '';  
		// Try to register the user
		$error = registerUser($username,$password1,$password2);
	}	
?>
   
<?php if ((!isset($_POST['submitBtn'])) || ($error != '')) {?>
      <div id="contentcenter">
		<h1>Install</h1>
      <form action="<?=$_SERVER['PHP_SELF']; ?>" method="post" name="registerform">
   
         Username:</td><td> <input class="text" name="username" type="text"  /><BR>
          Password:</td><td> <input class="text" name="password1" type="password" /><BR>
          Confirm password:</td><td> <input class="text" name="password2" type="password" />
          <br />
          <br />
         <input class="text" type="submit" name="submitBtn" value="Finish" /></td></tr>
      </form>    
<?php 
}   
    if (isset($_POST['submitBtn'])){

?>
<center>
           Result:
           <br />
 
<?php
	if ($error == '') {
			echo "Installation finished!
		
				Thank you for using WorkSimple
						<br>
<h1>Please <h1>delete the /install folder</h1> to prevent security issues. Also delete 'ni.txt' from the root directory </h2><br /><br />
Go <a href='../index.php'>Home</a> | <a href=../cp.php>Control Panel Home</a>";
}
	else echo $error;

?>
</center>
		<br/>
		<br/>
	</div>
<?php            
    }
?>
</div>
</body>
</html>