<?php include("includes/header.php"); ?>
<?php include("includes/auto_out.php"); ?>
<!DOCTYPE html>
<html>
<head>
  <title>Update Pin | <?php echo $sitename; ?></title>
  
     <!----------------------------------------------------------------------->
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
     <script src="bootstrap/js/jquery.min.js"></script>
     <script src="bootstrap/js/bootstrap.min.js"></script>
     <!----------------------------------------------------------------------->
     <link rel="icon" href="images/fav-icon.ico" type="image/x-icon" />
    <!-- <link rel="shortcut icon" href="images/fav-icon.ico" type="image/x-icon" />
     <!----------------------------------------------------------------------->
     <!-------------------Constumized CSS--------------------------->
     <link rel="stylesheet" type="text/css" href="css/style.cs">

     <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
     <style>
        body{
          background-color: #f5f5f5;
        }
      .icons-links{
        text-decoration: none;
        color: #555;
        font-size: 16px;
        font-weight: bolder;
      }
      .icons-links:hover{
        color:#0c2074;
        text-decoration: none;
      }
     </style>
     
</head>
<body>
  <?php  include("includes/dashboard_nav.php"); ?>
    <br>
  <div class="container-fluid">
    

        <div class="row">
      <div class="col-sm-2">
        <?php include("includes/sidebar.php"); ?>
          <?php include("includes/side.php"); ?>
      </div>
      <div class="col-sm-10">
               <div class="row">

                   <!------------------LEFT ROW ---------------------------->
                   <div class="col-sm-5">
                       
                      
                     
                       <!------------------------------------------------------>

                       <div class="row">
                         <div class="col-sm-12">
                            <div class="panel panel-default">
                             <div class="panel-body">
                               <h4 style=""><img src="images/3109399.png" width="43">  UPDATE PIN</h4>
                               <hr>

                               <div class="row">

                                <div class="col-sm-12" align="">


                                  <?php
                                    if(isset($_POST["pinbtn"])){

                                      //GET ALL VAIRABLES
                                      $my_account = $_POST["my_account"];
                                      $old_pin = $_POST["old_pin"];
                                      $new_pin = $_POST["new_pin"];
                                      $new_pin2 = $_POST["new_pin2"];

                                      //Check if password is correct with db pass
                                      if($db_account_pin == $old_pin){

                                        //Check if Pin==Pin2
                                        if($new_pin == $new_pin2){
                                            //Update new pin
                                            $query = mysqli_query($conn, "UPDATE users SET account_pin = '$new_pin' WHERE id = '$u_dbid'");
                                            echo "<div class='alert alert-success'><i class='glyphicon glyphicon-ok'></i> Account Pin Updated!</div>";
                                        }else{
                                            echo "<div class='alert alert-danger'><i class='glyphicon glyphicon-warning-sign'></i> New pin does not match!</div>";
                                        }
                                         
                                      }else{
                                        echo "<div class='alert alert-danger'><i class='glyphicon glyphicon-warning-sign'></i> Invalid Old Account Pin!</div>";
                                      }

                                    }
                                  ?>


                                  <div class="alert alert-info">Fill in the form below to update your transaction pin.</div>



                                   <form action="" method="POST">
                                     <div class="form-group">
                                      <label>My Account:</label>
                                       <select class="form-control input-lg" name="my_account" style="border-radius: 0px;">
                                         <option><?php echo $account_number; ?> - <?php echo ucfirst($firstname)."&nbsp;".ucfirst($middlename)."&nbsp;".ucfirst($lastname) ?></option>
                                       </select>

                                       <br>


                                       <label>Old Pin:</label>
                                       <input type="number" class="form-control input-lg" name="old_pin" style="border-radius: 0px;" placeholder="********" autocomplete="none" required/>

                                       <br>

                                       <label>New Pin:</label>
                                       <input type="number" class="form-control input-lg" name="new_pin" style="border-radius: 0px;" placeholder="********" autocomplete="none" required/>

                                       <br>

                                       <label>Confirm New Pin:</label>
                                       <input type="number" class="form-control input-lg" name="new_pin2" style="border-radius: 0px;" placeholder="********" autocomplete="none" required/>

                                       <br>

                                       <button type="submit" name="pinbtn" class="btn btn-primary" style="border-radius: 0px;">Update Pin</button>
                                     </div>
                                   </form>
                                </div>


                                 
                               </div>

                               <br>
                               
                             </div>
                           </div>
                         </div>
                       </div>
                       <!------------------------------------------------------>
                       
                   </div>
                   <!-----------------/LEFT ROW ---------------------------->

                   <!------------------------------------------------------->

                   <!------------------RIGHT ROW --------------------------->
                   <div class="col-sm-4">

                  
                    
                   </div>
                   <!-----------------/RIGHT ROW --------------------------->
               </div>
      </div>
    </div>
  </div>
</body>
</html>