<?php
    session_start();
    //error_reporting(E_ALL); 
    //ini_set('display_errors', 1);
    include('functions/userfunctions.php');
    include('config/dbcon.php');
    include('includes/header.php');

      if(isset($_SESSION['auth']))

      {

        $_SESSION['message'] = "You are already logged in.";

        header('Location: index.php');

        exit();

      }
 $checkforgotpw1 = $_GET['pwreset1'];
 $checkforgotpw2 = $_GET['pwreset2'];
 $checkforgotpw3 = $_GET['pwreset3'];
 $checkforgotpw4 = $_GET['pwreset4'];
 if($checkforgotpw1 && $checkforgotpw2 && $checkforgotpw3 && $checkforgotpw4){
    
    
    ?>
    <div class="container py-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h4>Reset Password</h4>
                    </div>
                    <div class="card-body">
                        <form action="functions/authcode.php" method="POST">
                            <div class="mb-3">
                                <input type="hidden" name="name" value="<?= $checkforgotpw1;?>">
                                <input type="hidden" name="id" value="<?= $checkforgotpw2;?>">
                                <input type="hidden" name="email" value="<?= $checkforgotpw3;?>">
                                <input type="hidden" name="phone" value="<?= $checkforgotpw4;?>">
                                <label for="exampleInputPassword1" class="form-label">Password</label>
                                <input type="password" name="password" class="form-control" placeholder="Enter Your Password" id="exampleInputPassword1">
                            </div>
                            <div class="mb-3">
                                <label  class="form-label">Confirm Password</label>
                                <input type="password" name="cpassword" class="form-control" placeholder="Confirm Your Password">
                            </div>
                                <button type="submit" name="resetmailpw_btn" class="btn btn-primary">Set New Password</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
     <?php           
 }else{
      ?>

    <div class="container py-5">

        <div class="row justify-content-center">

            <div class="col-md-6">

                <div class="card">

                    <div class="card-header">

                    <h4>Reset Password</h4>

                    </div>

                    <div class="card-body">

                        <form action="functions/authcode.php" method="POST">

                        <div class="mb-3">

                        <label for="exampleInputEmail1" class="form-label">Email address :</label>

                        <input type="email" name="email" class="form-control" id="exampleInputEmail1" placeholder="Enter Your Email" aria-describedby="emailHelp">

                        </div>

                        <button type="submit" name="forgotpw_btn" class="btn btn-primary">Send E-mail</button>

                    </form>

                    </div>

                </div>



            </div>

        </div>

    </div>
<?php
}
?>

    <?php include('includes/footer.php');?>