<?php
	include_once('config.php');   
	//include_once(ABS_PATH.'/custom_function/default.php');   
	if(isset($_SESSION['custId'])) 
    {
          header("Location: ".ROOTPATH."/");
         die;
    }  
      
        
        if(isset($_POST['submitRegister']))
        {  
            $CustId = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'),0, 8); 
            // $testOtp = rand(3445,4443); 
            //$_SESSION['LoginOtPSys'] = $testOtp; 
            
            $address = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'),0, 15); 

            $stmt=$conn->prepare("insert into   pw__usr (name,ph_no,cust_id,passwprd,is_active,address,email,verify) values(:name,:ph_no,:cust_id,:passwprd,:is_active,:address,:email,:verify)  ");          
            $stmt->bindValue(':name', $_POST['Fname'], PDO::PARAM_STR); 
            $stmt->bindValue(':ph_no',$_POST['ph_no'], PDO::PARAM_STR); 
            $stmt->bindValue(':address',$_POST['address'], PDO::PARAM_STR); 
            $stmt->bindValue(':email',$_POST['email'], PDO::PARAM_STR); 
            $stmt->bindValue(':cust_id', $CustId, PDO::PARAM_STR);   
            $encrypted_pwd = bin2hex(openssl_encrypt($_POST['passwprd'],'AES-128-CBC', $Pwdkey));   
            $stmt->bindValue(':passwprd',$_POST['passwprd'] , PDO::PARAM_STR);    
            $stmt->bindValue(':is_active',1 , PDO::PARAM_STR);    
            $stmt->bindValue(':verify', $address , PDO::PARAM_STR);    
            $stmt->execute();    
            $_SESSION['RegistrationCmpl'] = "Registration successfully completed!!";
            
            $subject = "Registration on meerindia";  
            $template_type = 1;
            $attachment = '';   
            $decrypted  = ROOTPATH.'/verifyemail.php?address='.$address;              
            header("Location: login.php");
            die;
        }  
include_once("view/register.php");
?>