<?php include("../templates/header.php"); ?>
<?php include("check_admin.php"); ?>

<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title">เปลี่ยนรหัสใหม่</h3>
  </div>
  <div class="panel-body">

   <?php
	
	include("../config/mysql_connect.php");

	$pwd_id = $_REQUEST['id'];

	if(isset($_POST["save"])){

		$password = $_POST['password'];

		$salt = 'fq7wrt3ygio8p5axd4h9j0kl2zcevb1nm6su';
		$hash_pwd = hash_hmac('sha256', $password, $salt);

		$sql_update = "update tb_account set acc_pass='$hash_pwd' where acc_id='$pwd_id'";
		$objQuery = mysqli_query($link,$sql_update);

		if($objQuery){
			echo "<meta http-equiv=refresh content=0;url=member.php>";
		}
		else{
			echo "<div class='alert alert-danger'>
			<button type='button' class='close' data-dismiss='alert'>&times;</button>
			<strong>Alerts!</strong> ล้มเหลว </div>";
		}

	}

	?>
<form class="form-horizontal" method="post">
<br>
  <fieldset>
    <div class="form-group">
      <label for="input" class="col-lg-2 control-label">Password</label>
      <div class="col-lg-9">
        <input type="password" class="form-control" name="password" placeholder="Password">
      </div>
    </div>

        <div class="form-group">
      <div class="col-lg-10 col-lg-offset-2">
      	<a href='dashboard.php' class='btn btn-default'>ย้อนกลับ</a>
        <button type="submit" class="btn btn-primary" name="save">บันทึก</button>
      </div>
    </div>

  </fieldset>
</form>


  </div>
</div>

<?php include("../templates/footer.php"); ?>