<!--- 

Developer: Coralys Cubero Rivera
Fall 2018

This script deletes an association between a questionnaire and an experience, then returns 
the user to the experiences main page. 



Updated by: Víctor A. Hernández
Summer 2019

--->

<?php
	
	require_once 'processes/config.php';
	require_once 'processes/dbh.inc.php';
	
	// IF USER ENTERS PAGE AFTER YES BUTTON HAS BEEN PRESSED (FROM confirmDeleteQuestionnaireExperience.php), DISASSOCIATE QUESTIONNAIRE FROM EXPERIENCE IN THE DATABASE
	// ELSE DO NOTHING
	if(isset($_GET['del']) AND isset($_GET['exp'])) {		
		$query = "DELETE FROM `experience_questionnair` WHERE `id_questionnair`='".$_GET['del']."' AND `id_experience`='".$_GET['exp']."';";
		if(!mysqli_query($connection, $query)) die("Error: ".mysqli_error($connection));
		// WHY NOT USE header INSTEAD OF window.top.location?
		//header('Location: http://emaapp.online/admin_nuevo/viewExperience.php?view='.$_GET['exp']);
		//exit();
		echo "<script>window.top.location='http://emaapp.online/admin_nuevo/viewExperience.php?view=".$_GET['exp']."'</script>";
	}