<?php 
ob_start();

include "db_conx.php"; // connecting to the database
$uid= $_GET['custid'];

// ======== getting for personal identification 
	$sql_delete = "SELECT * FROM personal_information WHERE id = '$uid'";
	$query_delete = $db_conx->query($sql_delete);
	$row_delete = mysqli_fetch_assoc($query_delete);
	
	$block = $row_delete['block'];
	$first_name = $row_delete['first_name'];
	$last_name = $row_delete['last_name'];
	$per_email = $row_delete['email'];

	$full_name = $first_name.' '.$last_name;


	switch ($block) {
		case '0':
			$block_no = 1;
			break;

		case '1':
			$block_no = 0;
			break;
		
		
	}
	$sql_block = "UPDATE personal_information SET block = '$block_no' WHERE id = '$uid' ";
	$query_block = $db_conx->query($sql_block);


	// now its time to send mail after blocking 
	if($block_no == 1){
		// then send this mail 
		
	// // Subject
		$subject = $sitename.'| Account Blocked';

		// // Message
		$message = '
		<html>
		<head>
		<title> Malicious Activity Discovered </title>
		</head>
		<body>
			<img src = "https://'.$sitelink.'/images/logo.png" style="height:80px;">
			<br />
			

			<p> <b>Dear Esteem Customer </b>  
			<br />

				We Regret to inform you that  access to your Account has been blocked because of suspicious login attempt  from an usual IP address.
				<br />

				Other reasons could be any of the following:
					<br />



				Wrong combination of access code or use of unknown device may prompt this and your account has been placed on "post no debit".
				Sequel to the above reasons,your Account  has been placed on (PND) Your account can only be credited and no debit transactions can pull through your account Henceforth. 
					<br />


				To unlock your Account contact our service help Desk with valid information about your account or come in person to any of our branch to sign some Bio-metric documents update placed on your account for security reasons.
					<br />


				We regret any inconvenience this may cause you. <br />

				We are poised to serving you better <br />

				Best Regards <br />
				'.$sitename.'
			</p>
		

		</body>
		</html>
		';

		// To send HTML mail, the Content-type header must be set
		$headers[] = 'MIME-Version: 1.0';
		$headers[] = 'Content-type: text/html; charset=iso-8859-1';

		// Additional headers
		$headers[] = 'To: '.$per_email.' ';
		$headers[] = 'From: '.$sitename.' <'.$site_email.'>';

		// //sending the mail 
		$mail = mail($per_email, $subject, $message, implode("\r\n", $headers));

		if($mail){
			echo 'success';
		}else{
			echo 'failed';
		}

	}else if($block_no == 0){

		// Subject
		$subject = $sitename.'| Account Unblocked';

		// // Message
		$message = '
		<html>
		<head>
		<title> Malicious Activity Discovered </title>
		</head>
		<body>
			<img src = "https://'.$sitelink.'/images/logo.png" style="height:80px;">
			<br />
			

			<p> <b>Dear Esteem Customer </b>  
			<br />

			Congratulations your Account has been successful unblocked <br />

			All transaction can pull through your Account now.


				Best Regards <br />
				'.$sitename.'
			</p>
		

		</body>
		</html>
		';

		// To send HTML mail, the Content-type header must be set
		$headers[] = 'MIME-Version: 1.0';
		$headers[] = 'Content-type: text/html; charset=iso-8859-1';

		// Additional headers
		$headers[] = 'To: '.$per_email.' ';
		$headers[] = 'From: '.$sitename.' <'.$site_email.'>';

		// //sending the mail 
		$mail = mail($per_email, $subject, $message, implode("\r\n", $headers));
		if($mail){
			echo 'success';
		}else{
			echo 'failed';
		}


	}


	header('location:../a/account.php');
	


ob_end_flush();

?>