<?php        
	include("../models/connect.php");	
	$id = $_POST["id"];
	$conferencista = $_POST["conferencista"];
	$urlRedirect = $_POST["url"];

	$query = mysqli_query($connect,"SELECT * FROM Agenda WHERE id = '".$id."' ");
	$data = mysqli_fetch_array($query);
	
	$new_conferencistas = array();
	$conferencistas = json_decode( $data["conferencistas"] );
	
	foreach($conferencistas as $conf){
		if( $conferencista != $conf ){
			array_push( $new_conferencistas, $conf );
		}
	}

	$new_conferencistas = json_encode($new_conferencistas);
	mysqli_query($connect,"UPDATE Agenda SET conferencistas = '".$new_conferencistas."' WHERE id = '".$id."' ");

?>

<script>
	window.location = "<?php echo $urlRedirect; ?>";
</script>

