<!--- 

Developer: Coralys Cubero Rivera
Fall 2018

This script deletes an association between a question and a questionnaire,  and then returns 
the user to the 'questionnaires' 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 confirmDeleteQuestionQuestionnaire.php), DISASSOCIATE QUESTION FROM QUESTIONNAIRE IN THE DATABASE
	// ELSE DO NOTHING
	if(isset($_GET['del']) AND isset($_GET['quest'])) {
		$query = "DELETE FROM `questionnair_question` WHERE `id_question`=".$_GET['del']." AND `id_questionnair`=".$_GET['quest'].";";
		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/viewQuestionnaire.php?view=".$_GET['quest']);
		//exit();
		echo "<script>window.top.location='http://emaapp.online/admin_nuevo/viewQuestionnaire.php?view=".$_GET['quest']."'</script>";
	}