<?php
	include_once('config.php');   
	include_once(ABS_PATH.'/custom_function/default.php');   
    if(isset($_SESSION['custId'])) 
    {
          header("Location: ".ROOTPATH."/");
         die;
    }  
                
                if(isset($_POST['submit']))
                {    
                    $stmt=$conn->prepare("select email,passwprd from  pw__usr where email=:email ");      
                    $stmt->bindValue(':email',$_POST['email'], PDO::PARAM_STR);  
                    $stmt->execute();
                     
                    if( $stmt->rowCount() > 0)
                    {   
                        $starlineRT = $stmt->fetch(PDO::FETCH_OBJ);   
						$decrypted = openssl_decrypt(hex2bin($starlineRT->passwprd),'AES-128-CBC',$Pwdkey);
                         
                        $subject = "Your Password";  
                        $template_type = 1;
                        $attachment = '';  
                        
                        $message="
                        <tr>
                        <td align='left' valign='top'>
                        <h4 style='font-weight:bold; padding:2px 2px; margin:3px; text-align:left; color:#002368;'>Dear user,</h4>
                        <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> Thanks for contact us. Please find your password as  follows </h5> 
                        <h5 style='font-weight:bold; padding:2px 2px; margin:0px; text-align:center; color:#002368;'> $decrypted </h5> 
                        </td>
                        </tr>";   
                        SendMail($_POST['email'],$subject,$message,$template_type,$attachment);    
                        $_SESSION['thanksforemail'] = "Your password has been resent your email id"; 
                        header("Location: forgetpassword.php");
                        die; 
                    }else
                    {
                        $_SESSION['thanksforemail'] = "Sorry Please enter registered email id"; 
                        header("Location: forgetpassword.php");
                        die; 
                    }
                }


include_once("view/forgetpassword.php");
?>