<?php
include 'include/db.php';
$id= isset($_REQUEST['id']) ? $_REQUEST['id'] : '';

$query="select * from registration where LOWER(unique_user_id) = '".strtolower(trim($id))."' ";
$connection=mysqli_query($conn,$query);
if(mysqli_num_rows($connection)>0)
{
    while($rows=mysqli_fetch_array($connection))
    {
        $email=$rows['user_email'];
        $mobile=$rows['user_mobile'];
        $transaction_pwd=$rows['transaction_pwd'];
        $account_pwd=base64_decode($rows['user_pwd']);
        //  send user details througn text message
          /*  $message= 'User account details';
        	$YourAPIKey='145236e8-01f8-11e9-a895-0200cd936042';
    		$From='FDSPHO';
    		$To=$mobile;
    		$Msg=$message;
    
    		### DO NOT Change anything below this line

    		$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
    
    		$url = "https://2factor.in/API/R1/?module=TRANS_SMS&apikey=$YourAPIKey&to=$To&from=FDSPHO&templatename=Customer+Details&var1=:$id&var2=:$account_pwd&var3=:$transaction_pwd"; 
    		$ch = curl_init(); 
    		curl_setopt($ch,CURLOPT_URL,$url); 
    		curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_POSTFIELDS,"From=$From&To=$To&Msg=$Msg"); 
    		curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    		curl_exec($ch); 
    		curl_close($ch);
    		*/
        //  send user details through email
        if($email!='')
        {
            $to = $email;
            $subject = "User account details";
            $txt = "Unique Id - " .$id.
                    "\nAccount Password  - " .$account_pwd.
                    "\nTransaction Password - " .$transaction_pwd;
            $headers = "From: info@fairyindia.com";
            echo 'email send';
            if(mail($to,$subject,$txt,$headers))
            {
                echo "mail send successfully";
            }
        }
        else
        {
            echo 'not found';
        }
        
    }
}

?>