<?php
include('../../../function/__data_app_db.php');
$__data_ction = 'false';
 $_name_in_jsnj  = $__go_to = $errData = $password= $password_salt='';
if(isset($_POST["tkn"]) && $_POST["tkn"] == $_SESSION['signup_token']){
if(isset($_POST["password"])){

  if (empty($_POST["password"])) {
    $errData .= "| All field is required |";
  } else {
      if($_POST["password"] == $_POST["cpassword"]) {
          $password = validate_jsnj_data(md5($_POST["password"]));
          $password_salt = validate_jsnj_data($_POST["password"]);
      } else {
          $errData .= "| Password do not match |";
      }
  };
$login = $_SESSION['user_num'];
  $db_query = "update  my_admin set password='$password',	password_salt='$password_salt' where id ='$login'";
  
 if($errData=='')
 {
  if(mysqli_query($_conn_db, $db_query)) {
    $__notif_titile = 'Congratulations';
	$__notif_disc = 'Password change successfully';
	$__notif_type = 'success';
	$__go_to = '';
	$__data_ction = 'true';
	  
  }
  else{
	$__notif_titile = 'Oops!';
	$__notif_disc = 'Somthing want wrong please reload this page';
	$__notif_type = 'danger';
  }
 }else{
   $__notif_titile = 'Oops!';
   $__notif_disc = $errData;
   $__notif_type = 'warning';
 } 
} else {
	$__notif_titile = 'Error';
	$__notif_disc = 'Password Is required';
	$__notif_type = 'danger';
}
	
$dataResult = array('page' => 'change-password', 'data_action' => $__data_ction, 'notif_title' => $__notif_titile, 'notif_desc' => $__notif_disc,  'notif_type' => $__notif_type);
echo json_encode($dataResult);
} else {
    echo 'lol';
};
?>