<?php 
	error_reporting(0);
	define('INCLUDE_CHECK',true);
	session_start();
	require ('classes/config.php');
	require_once('classes/session.php');
	
	$sql = ("SELECT * FROM staff_details WHERE id='{$_SESSION['id']}' AND staff_no='{$_SESSION['staffno']}'");
	$res = $conn->query($sql);  
	//	echo $_SESSION['id'];
//while($srows = mysql_fetch_array($sql)){
			 while($row = $res->fetch_assoc()) {
					$surname = $row['surname'];
					$othernames = $row['othernames']; 
					$staffno = $row['staff_no'];
					$password = $row['authp'];
			$result = $conn->query($sql); 
				}

 
	if(isset($_POST['update'])){

            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 ($err == ""){
				//	$password = $_POST['password'];
					$password = $_POST['vpassword'];
            		$sqludate=("UPDATE staff_details SET authp='$password' where staff_no='{$_SESSION['staffno']}'");
					$res = $conn->query($sqludate); 
                    }else{
                        $msg ='<div class=bg-warning>Error Info.!</div>';
                    }
            }
            
?>    
<title>OSCOTECH, ESA-OKE :: Staff-Dashboard > Change of Password</title>
    
   
        <div id="page-wrapper" >
            <div id="page-inner">

                    <!-- /. ROW  -->
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Change of Password Form
                        </div>
                        <?php echo $msg; ?>
                        <div class="panel-body">
                        <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 ?>" disabled="disabled">
                            </div>
                            <div class="form-group">
                                <label>Other Names:</label>
                                <input class="form-control" placeholder="Other Names" name="othername" id="othername" value="<?php echo $othernames ?>" disabled="disabled">
                            </div>
                            <div class="form-group">
                                <label>Staff No:</label>
                                <input class="form-control" placeholder="Staff Number" name="staffno" id="staffno" value="<?php echo $staffno ?>" disabled="disabled">
                            </div>
                            <div class="form-group">
                                <label>Previous Password:</label>
                                <input class="form-control"  type="text" name="" id="" value="<?php echo $password ?>" require>
                            </div>
                            <div class="form-group">
                                <label>New 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"  require>
                            </div>
                          <div class="form-group">
                            <label>Verify Password:</label>
                              <input name="vpassword"  type="password" class="form-control" id="vpassword" placeholder="Verify Password"  require>
                            </div>
                                <button type="submit" name="update" class="btn btn-success">Update</button>
                            <button type="reset" class="btn btn-danger" VALUE="CLOSE" ONCLICK="window.location='dashboard.php?action=form_processing'">Close</button>
                        </form>
                          </div>
                        </div>
                    </div>
                </div>
            </div>
                    <!-- /. ROW  -->

                 <hr />
               
    </div>
             <!-- /. PAGE INNER  -->
            </div>
         <!-- /. PAGE WRAPPER  -->
        </div>
     <!-- /. WRAPPER  -->
