<?php require ("header.php") ?> 



<?php

//   session_start();
// require_once("achieved/db.php");

// require_once("achieved/db2.php");

// $sql=mysql_query("SELECT customers,active,completed FROM admin");


// $add=rand(1, 5);
// $adda=rand(3, 50);
// $active=rand(100, 500);

// $customers=$row['customers']+$add;
// $completed=$row['completed']+$adda;
// $update=mysql_query("UPDATE admin SET customers='$customers',completed='$completed'");

// if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE) {
// header("Location: " . $config_basedir ."../accounts/index.php");
// }


// if($_POST['action']=='Login')
// {
if (isset($_POST['action'])) {
    
    
  
   
     $reset = mysql_real_escape_string($_POST['reset']);
     $npassword = mysql_real_escape_string($_POST['npassword']);
     $cpassword = mysql_real_escape_string($_POST['cpassword']);
     
    $passcode = "SELECT * FROM logins WHERE  reset = '$reset'  ";
    $passkey = mysql_query($passcode);
    $numrows = mysql_num_rows($passkey);
  
  
  
    if($numrows == 1 && $npassword == $cpassword)
    {
   
    $addresssql = mysql_query("UPDATE logins SET password='$npassword', reset='NULL'  WHERE reset = '$reset'");
    
    //  echo mysql_error();
     
      $success_psw="<div class='alert alert-success' style='margin-bottom:20px;'>Your account password has been changed successfully <meta http-equiv='refresh' content='10; url=login.php' /></div>";
    
    
      }
      
      
      
      
      
     else
    {
        $error5= "<div class='alert alert-danger' align='center'>Your password does not match</div>";

    }	
     
     
  
  
   

}   
          

?>
    
          
          
          
          
          
          
          
          
             <section id="login" class="auth-height">
                      <div class="row full-height-vh m-0">
                        <div class="col-12 d-flex align-items-center justify-content-center">
                          <div class="card overflow-hidden">
                            <div class="card-content">
                              <div class="card-body auth-img">
                                <div class="row m-0">
					
					
					<h3><?php echo $domain_name?></h3>
                                 
                                 
                                  <div class="col-lg-6 d-lg-flex justify-content-center align-items-center auth-img-bg p-3">
                                    <img src="../img/LOGO.png" alt="Braemuir Corporate Limited" class="img-fluid" width="300" height="100%">
                                 
                                 <br>
                                  
                             <!-- Register Form Starts -->
                      <?php 
if(isset($success_psw)){
    echo $success_psw;
}

elseif(isset($error5)){
    echo $error5;
}
?>
          </div>
                                  <div class="col-lg-6 col-12 px-4 py-3">
            
            
            
           <form class="login-form" method="POST" action="">
               
               
                 
          
          
            <h4 class="mb-2 card-title">Login</h4>
            <p>Welcome back, please reset your password.</p>
              <?php
$reset = $_GET['reset'];

$ordsql = "SELECT * from logins WHERE reset = " . $reset; 
$ordres = mysql_query($ordsql);
$ordrow = mysql_fetch_assoc($ordres);
       
   
	 if($ordrow > 0)
    {
        echo " 
      
    
    
     <div class='form-group'>  
      <label for='New-password'>New Password</label>
      <input class='form-control border-primary' type='text' name='npassword' class='form-control'   placeholder='' required/>
      </div>
      
      
       <div class='form-group'>
         <label for='confirm-password'>Confirm Password</label>
      <input class='form-control border-primary' type='text' name='cpassword' class='form-control'   placeholder='' required/>
      </div>
      
       <input class='form-control border-primary' type='hidden' name='reset' class='form-control'   value='"  . $ordrow['reset'] . "' readonly/>


 <div class='card-footer'>
                        <button type='submit' name='action' class='btn btn-primary'>RESET PASSWORD</button>
                     </div>


 ";
    }
   
   
   
   
   
   
    else
 echo  "ERROR, THERE IS NO RECORD FOUND HERE";
 ?>   
          
       
            </div>
            <hr>
            <div class="d-flex justify-content-between align-items-center">
              <h6 class="text-primary m-0"><a href="../" class=""><i class="fa fa-arrow-left"></i> Home</a></h6>
              <div class="login-options">
                    <div id="google_translate_element" style="width: auto;padding: 0;"></div>
                    <script type="text/javascript">
                        function googleTranslateElementInit(){
                          new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element');
                        }
                    </script>
              </div>
            </div>
        </form>                                   
                                  </div>
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                         </div>

                   
                   
                   
                   
                   
                    </section>
                  
          
          
          <?php require ("footer.php") ?> 