36 lines
		
	
	
		
			744 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			744 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<?php
 | 
						|
 | 
						|
session_start();
 | 
						|
 | 
						|
if (!isset($_SESSION['uid'])) {
 | 
						|
	header('Location: /admin/login.php');
 | 
						|
	die;
 | 
						|
}
 | 
						|
 | 
						|
$email = $_POST['email'];
 | 
						|
if (!isset($email)) {
 | 
						|
	http_response_code(400);
 | 
						|
	die("Error: no email provided to unsubscribe");
 | 
						|
}
 | 
						|
 | 
						|
$conn = new mysqli("localhost", "mileslinden", "Daiso@6969", "mileslinden");
 | 
						|
 | 
						|
$query = $conn->prepare("DELETE FROM subscribers WHERE email = ?");
 | 
						|
if (!$query) {
 | 
						|
	http_response_code(500);
 | 
						|
	die("Error: {$conn->error}");
 | 
						|
}
 | 
						|
$query->bind_param("s", $email);
 | 
						|
if (!$query->execute()) {
 | 
						|
	http_response_code(500);
 | 
						|
	die("Error {$query->errno}: {$query->error}");
 | 
						|
}
 | 
						|
 | 
						|
if ($query->affected_rows === 0) {
 | 
						|
	http_response_code(400);
 | 
						|
	die("Error: that email address does not exist");
 | 
						|
} else {
 | 
						|
	header('Location: /admin');
 | 
						|
	die;
 | 
						|
}
 |