<?php
session_start();
include_once 'po-library/po-database.php';
include_once 'po-library/po-function.php';
$val = new Povalidasi;
if (!$_SESSION['submit']){
	echo "error|Terjadi Kesalahan";
}else{
	if(empty($_POST['email_address'])){
		echo "error|Terjadi Kesalahan";
	}else{
		$tablecari = new PoTable('subscribe');
		$currentCari = $tablecari->numRowBy(email, $_POST['email_address']);
		if ($currentCari > 0){
			echo "error|Email telah berlangganan";
		}else{
			$email = $val->validasi($_POST['email_address'],'xss');
			$table = new PoTable('subscribe');
			$table->save(array(
				'email' => $email
			));
			unset($_POST);
			echo "success|Anda berhasil berlangganan";
		}
	}
}
?>