
<?php
session_start();
include 'include/db.php';

$email=$_REQUEST['email'];
$secrec_code=$_REQUEST['val'];

$query="select * from email_verify INNER JOIN registration ON email_verify.email=registration.user_email 
where email_verify.email='$email' AND email_verify.email_security_code='$secrec_code'";
$connection=mysqli_query($conn,$query);
if(mysqli_num_rows($connection)>0)
{
    while($rw=mysqli_fetch_array($connection))
    {
        $id=$rw['unique_user_id'];
    }
	$qry="update registration set email_verified='1' where unique_user_id='$id'";
	$con=mysqli_query($conn,$qry);
	if($con)
	{
		$_SESSION['unique_user_id']=$id;
		$_SESSION['email_verified']='1';
	
	     //   create random transaction password
	        $random_pwd=rand(00000,99999);
	    //  update transaction password from registration table
	        $qry11="update registration set transaction_pwd='$random_pwd' where unique_user_id='$id' ";
	        $connection11=mysqli_query($conn,$qry11);
	        if($connection11)
	        {
    		//  verification success email send to user and also send 6 digit transaction password
    		    $to = $email;
                $subject = "You have registration successfully";
                $txt = "Your user id is- " .$id. "\nYour transaction password  is- ".$random_pwd;
                $headers = "From: info@astrosyspvtltd.com" . "\r\n" .
                "CC: apurbakarar7063@gmail.com";
                
                if(mail($to,$subject,$txt,$headers))
                {
                 //echo 'mail send successfully';
                }
                else
                {
                	//echo 'Not send';
                }
	        }
	        else
	        {
	            
	        }
	            
	}
	
}
else
{
	echo '2';
}

?>