<?php
session_start();
@$userKey = $_SESSION['loginKey'];

if($userKey == "")
{
    echo "<script>window.open('login.php','_self')</script>";
}


include "control/activity.php";
$dd = new activity();


$table = "userdetails";
$condition = " where userKey='$userKey'";
$getuserdetails = $dd->single($table,$condition);
$oldPass = $getuserdetails['password'];
$table="admin_calculation";
$condition="null";
$getAdminDetails=$dd->single($table,$condition);
$fevicon = $getAdminDetails['favicon'];
?>



<!DOCTYPE html>
<html lang="en" translate="no">
<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/svg+xml" href="temp_img/<?= $fevicon; ?>">
    <meta name="google" content="notranslate">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Goaclub</title>
    <link rel="stylesheet" href="css/slick.css" />
    <link rel="stylesheet" href="css/modules.css" />
    <link rel="stylesheet" href="css/style.css" />
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/slick.min.js" type="text/javascript"></script>
    <script src="js/main.js" type="text/javascript"></script>
</head>
<body>
    <div id="app">
       <div class="mian">
         <!--NavBar-->
         <div class="navbar">
            <div class="navbar-fixed" style="background: linear-gradient(90deg, rgb(207, 3, 5) 0%, rgb(242, 63, 58) 100%);">
                <div class="navbar__content">
                <div onclick="getBack()" data-v-905dfe8c="" class="navbar__content-left"><div data-v-905dfe8c="" class="backIcon"></div></div>
                    <div data-v-905dfe8c="" class="navbar__content-center"><div data-v-905dfe8c="" class="navbar__content-title"> Change login password </div></div>
                    
                </div>
            </div>
        </div>
        <!--NavBar-->

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

        </div>
       <div class="LoginP-container">
            <form method="post">
            <div class="LoginP-container-form">
                <div data-v-34ec8998="" data-v-194e2271="" class="passwordInput__container">
                    <div data-v-34ec8998="" class="input-label passwordInput__container-label">
                        <img data-v-34ec8998="" class="passwordInput__container-label__icon" data-src="images/password-c2d8d12b.png" src="images/password.png" lazy="loaded" /><span data-v-34ec8998="">Login password</span>
                    </div>
                    <div data-v-34ec8998="" class="passwordInput__container-input">
                        <input id="oldpassword" name="oldpassword" data-v-34ec8998="" type="password" placeholder="Please enterLogin password" maxlength="32" autocomplete="new-password" />
                        <span toggle="#oldpassword" class="fa fa-fw fa-eye field-icon oldpassword">
                            <img data-v-b0ac9d23="" src="images/view-icon.png" class="eye hid_pass">
                            <img data-v-b0ac9d23="" src="images/eyeVisible-09720f5f.png" class="eye show_pass">
                        </span>
                    </div>
                </div>

                <div data-v-34ec8998="" data-v-194e2271="" class="passwordInput__container">
                    <div data-v-34ec8998="" class="input-label passwordInput__container-label">
                        <img data-v-34ec8998="" class="passwordInput__container-label__icon" data-src="images/password-c2d8d12b.png" src="images/password.png" lazy="loaded" /><span data-v-34ec8998="">New login password</span>
                    </div>
                    <div data-v-34ec8998="" class="passwordInput__container-input">
                        <input id="newPassword" name="newPassword" data-v-34ec8998="" type="password" placeholder="Please enterNew login password" maxlength="15" autocomplete="new-password" />
                        <span toggle="#newPassword" class="fa fa-fw fa-eye field-icon newPassword">
                            <img data-v-b0ac9d23="" src="images/view-icon.png" class="eye hid_pass">
                            <img data-v-b0ac9d23="" src="images/eyeVisible-09720f5f.png" class="eye show_pass">
                        </span>
                    </div>
                </div>

                <div data-v-34ec8998="" data-v-194e2271="" class="passwordInput__container mgb48">
                    <div data-v-34ec8998="" class="input-label passwordInput__container-label">
                        <img data-v-34ec8998="" class="passwordInput__container-label__icon" data-src="images/password-c2d8d12b.png" src="images/password.png" lazy="loaded" /><span data-v-34ec8998="">Confirm new password</span>
                    </div>
                    <div data-v-34ec8998="" class="passwordInput__container-input">
                        <input id="cpassword" name="cpassword" data-v-34ec8998="" type="password" placeholder="Please enterConfirm new password" maxlength="15" autocomplete="new-password" />
                        <span toggle="#cpassword" class="fa fa-fw fa-eye field-icon cpassword">
                            <img data-v-b0ac9d23="" src="images/view-icon.png" class="eye hid_pass">
                            <img data-v-b0ac9d23="" src="images/eyeVisible-09720f5f.png" class="eye show_pass">
                        </span>
                    </div>
                </div>

                <div data-v-194e2271="" class="LoginP-container-tips" style="display: none;"><span data-v-194e2271="">Entered twice the password does not match!</span></div>
                
                <div data-v-194e2271="" class="LoginP-container-remember"><span data-v-194e2271="">Contact customer service</span><i data-v-194e2271="" class="van-badge__wrapper van-icon van-icon-arrow" style="color: rgb(136, 136, 136);"></i></div>

                <div data-v-194e2271="" class="LoginP-container-button"><button name="saveChange" data-v-194e2271="">Save changes</button></div>


            </div>
            </form>
        </div>
    </div>
</body>

<script>
function getBack(){
    window.open('account.php','_self')
}
 $(".newPassword").click(function() {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var input = $($(this).attr("toggle"));
        if (input.attr("type") == "password") {
        input.attr("type", "text");
        } else {
        input.attr("type", "password");
        }
    });
    $(".oldpassword").click(function() {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var input = $($(this).attr("toggle"));
        if (input.attr("type") == "password") {
        input.attr("type", "text");
        } else {
        input.attr("type", "password");
        }
    });
    
    $(".cpassword").click(function() {
        $(this).toggleClass("fa-eye fa-eye-slash");
        var input = $($(this).attr("toggle"));
        if (input.attr("type") == "password") {
        input.attr("type", "text");
        } else {
        input.attr("type", "password");
        }
    });
    </script>

</html>

<?php
  if(isset($_POST['saveChange']))
  {
     $oldpassword = $_REQUEST['oldpassword'];
     $newPassword = $_REQUEST['newPassword'];
     $cpassword = $_REQUEST['cpassword'];

      if($oldPass == $oldpassword)
      {
         if($newPassword == $cpassword)
         {
             $table = "userdetails";
             $value = "password='$newPassword'";
             $condition = " userKey='$userKey'";
             $result = $dd->updateData($table,$value,$condition);
             if($result){
                echo "<script>alert('Change successfully..!!'),window.open('index.php','_self')</script>";
             }
         }
         else{
            echo "<script>alert('Sorry old Confirm password not match..!!')</script>";
         }
      }else{
        echo "<script>alert('Sorry old Password not match..!!')</script>";
      }
  }
?>