<?php
	error_reporting(0);
	define('INCLUDE_CHECK',true);
	session_start();
	require ('classes/config.php');
	require_once('classes/session.php');
	
	if ( $_SESSION['c']!=0){
		$sql = mysql_query("SELECT * FROM admin_account WHERE c='{$_SESSION['c']}' AND username='{$_SESSION['username']}'")or die ('An error occured ' . mysql_error());
				while($srows = mysql_fetch_array($sql)){
					$surname = $srows['surname'];
					$othername = $srows['othernames']; 
					$email = $srows['email'];
					$password = $srows['password'];
					$username = $srows['username'];
				}
	}
	
	if(isset($_POST['submit'])){

            if(strlen($_POST['password'])<6 || strlen($_POST['password'])>32){
                    $msg ='<div class=bg-warning>Your password must be between 6 and 32 characters!</div>';
                    $err = "yes";
                }
            if ($_POST['vpassword'] != $_POST['password']) {
                    $msg ='<div class=bg-warning>Your password confirmation do not match.</div>';
                    $err = "yes";
                }
            if(!checkEmail($_POST['email'])){
                    $msg ='<div class=bg-warning>Your email is not valid!</div>';
                    $err = "yes";
                }
            if ($err == ""){
					$surname = htmlspecialchars($_POST['surname']);
					$othername = htmlspecialchars($_POST['othername']);
					$email = htmlspecialchars($_POST['email']);
					$username = mysql_real_escape_string($_POST['username']);
					$password = mysql_real_escape_string($_POST['password']);
					
            		$sqludate=mysql_query("UPDATE admin_account set surname='$surname',othernames='$othername',email='$email',username='$username',password='$password',c='1',datereg=NOW() where id='{$_SESSION['id']}'")or die ('An error occured ' . mysql_error());
                    $_SESSION['c']=1;  
					
                    }else{
                        $msg ='<div class=bg-warning>Error Info.!</div>';
                    }
            }
?>
<title>OSCOTECH, ESA-OKE :: Admin-Dashboard > User Profile</title>


        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Adminitrator Setup</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            
            <div class="row">
                <div class="col-lg-12">
                	<?php echo $msg; ?>	
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            User Profile Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                    <form method="post" action="" role="form">
                                        <div class="form-group">
                                            <label>Surname:</label>
                                            <input class="form-control" placeholder="Surname" name="surname" id="surname" value="<?php echo $surname ?>" require>
                                        </div>
                                        <div class="form-group">
                                            <label>Other Names:</label>
                                            <input class="form-control" placeholder="Other Names" name="othername" id="othername" value="<?php echo $othername ?>" require>
                                        </div>
                                        <div class="form-group">
                                            <label>Email:</label>
                                            <input class="form-control" placeholder="Email Address" name="email" id="email" value="<?php echo $email ?>" require>
                                        </div>
                                        <div class="form-group">
                                            <label>Username:</label>
                                            <input class="form-control" placeholder="Username" name="username" id="username" value="<?php echo $username ?>" require>
                                        </div>
                                        <div class="form-group">
                                            <label>Password: <span style="color:#F00; font-size:11px;">Minimum of Six Digit</span></label>
                                            <input class="form-control"  type="password" placeholder="Password" name="password" id="password" value="<?php echo $password ?>" require>
                                        </div>
                                        <div class="form-group">
                                            <label>Verify Password:</label>
                                            <input class="form-control"  type="password" placeholder="Verify Password" name="vpassword" id="vpassword" value="" require>
                                        </div>
                                       	<?php// if ($_SESSION['c']!=0){ ?>
                                        	<button type="submit" name="submit" class="btn btn-success">Submit</button>
										<?php// } ?>
                                        <button type="reset" class="btn btn-danger" VALUE="CLOSE" ONCLICK="window.location='dashboard.php?action=home'">Close</button>
                                    </form>
                                </div>

        </div>
        <!-- /#page-wrapper -->
        

    </div>
    <!-- /#wrapper -->
   <?php $_SESSION['c']=1; ?>