<?php
	global $connection;
	$connection = mysql_connect("localhost", "webstagi_optoutu", "Chang3M3") or die(mysql_error());
	mysql_select_db("webstagi_optout");

	$user_senderid = $_POST["senderid"];
	$user_phone = $_POST["phone"];
	date_default_timezone_set('Asia/Dubai');
	$udate = date("Y-m-d H:i:s");
	$sql="INSERT INTO unsubscribe_optout(mobile,senderid,udate) values('$user_phone','$user_senderid','$udate')";
    $result=mysql_query($sql);

	if($result) {
		$toEmail = "navya.bogavalli@vectramind.com";
		$subject = "UnSubscribe";
		$message = '<html><body>';
		$message .= '<h1 style="color:#f40;">UnSubscribe!</h1>';
		$message .= '<p style="color:#080;font-size:18px;">Phone: '.$user_phone.' </p>';
		$message .= '<p style="color:#080;font-size:18px;">Sender ID:  '.$user_senderid.' </p>';
		$message .= '</body></html>';
		$mailHeaders  = "MIME-Version: 1.0" . "\r\n";
		$mailHeaders .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
		$mailHeaders .= "From: User@vectramind.com". "\r\n";
		
		if(mail($toEmail, $subject, $message, $mailHeaders)) {
			print "<p class='success'>Unsubscribed Successfully</p>";
			} 
			else {
			print "<p class='error'>Unable to send email Please contact admin'</p>";
		}
	}
?>