<?php
include('../../../dbconnection/dbconnection.php');

if(isset($_POST["btn_action"])){
if($_POST["btn_action"]==="subscribe"){
	$email=$_POST["email"];
	// ECHO $_POST["pg"];
	$sql=$connect->prepare("SELECT * FROM subscribers WHERE email='email'");
  $sql->execute();
 $count=COUNT($sql->fetchAll());
	if($count===0){
		
		$query = "
			INSERT INTO subscribers (email,date,status) 
			VALUES (:email,:date,:status)
			";
		$statement=$connect->prepare($query);
		$statement->execute(
			array(
				":email"		=>	$email, 
				":date" 		=>	time(),
				":status"		=>	"1", 
			)
		);
		$result = $statement->fetchAll();
			if(count($result))
			{
				echo 'Successfuly subscribed';
			}
	
	}else{
		
		echo "You are Already Subscribed";
	}
}
}

?>