SQL working properly
diff --git a/js/utils.js b/js/utils.js
index ec42a8a..228ffa4 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -5,12 +5,17 @@
     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
 };
 
-function send_request(id, msg) {
+function send_request(user, victim, msg) {
 	$.ajax({
 		'url': './php/request.php', 
 		'type': 'GET',
 		'contentType': 'application/json; charset=utf-8',
-		'data': { 'id': id, 'msg': msg }, 
+		'data': { 'user_id': user.id,
+				  'victim_id': victim.id,
+				  'user_quimata': user.quimata,
+				  'victim_quimata': victim.quimata,
+				  'msg': msg
+				}, 
 		'success': function(data) {
 			if (msg <= 2) $.notify('Confirmació enviada', 'success');
 			else $.notify('Resposta guardada', 'success');
@@ -23,19 +28,19 @@
 	});
 }
 
-function check_requests(requested, victimnom, victimid, userid) {			
+function check_requests(requested, user, victim) {	
 	let dead = false;
 	let killed = false;
 	
 	if (requested != 0) {
 		// Check for requests
 		if(requested == 1) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
-		if(requested == 2) killed = confirm("En/na " + victimnom + " ha dit que l'has matat, és veritat?");
+		if(requested == 2) killed = confirm("En/na " + victim.nom + " ha dit que l'has matat, és veritat?");
 		
 		// Confirm/deny request
-		if (dead) send_request(userid, 3); // confirm death
-		else if (killed) send_request(victimid, 3); // confirm kill
-		else send_request(userid, 4); // deny kill/death
+		if (dead) send_request(user, victim, "CONF DEAD"); // confirm death
+		else if (killed) send_request(user, victim, "CONF KILL"); // confirm kill
+		else send_request(user, victim, "DENY REQ"); // deny kill/death
 	}	
 
 	// Return mort
diff --git a/main.php b/main.php
index 298753a..5bf6765 100644
--- a/main.php
+++ b/main.php
@@ -14,11 +14,18 @@
 		?>
 		
 		<script>
-			let mort = <?=$user->mort?>;
-			let requested = <?=$user->requested?>;
-			let userid = <?=$user->id?>;
-			let victimid = <?=$victim->id?>;
-			let victimnom = "<?=$victim->nom()?>";
+			let user = {
+				'id': <?=$user->id?>,
+				'quimata': <?=$user->quimata?>,
+				'requested': <?=$user->requested?>,
+				'mort': <?=$user->mort?>
+			};
+			
+			let victim = {
+				'id': <?=$victim->id?>,
+				'quimata': <?=$victim->quimata?>,
+				'nom': "<?=$victim->nom()?>"
+			};
 		</script>
 	
 	</head>
@@ -37,18 +44,18 @@
 			</div>
 		</div>
 		<div id="butons">
-			<button id="win" onclick="js: send_request(<?=$victim->id?>,1);">L'he matat</button>
-			<button id="lose" onclick="js: send_request(<?=$user->id?>,2);">M'han matat</button>
+			<button id="win" onclick="js: send_request(user, victim, 'REQ KILL');">L'he matat</button>
+			<button id="lose" onclick="js: send_request(user, victim, 'REQ DEAD');">M'han matat</button>
 		</div>
 		
 		<script>
 			$(document).ready(function() {
 				let checking = setInterval(function() {
-					$.ajax({ url: "./php/checkrequests.php", data: { id: userid }, type: 'GET',
+					$.ajax({ url: "./php/checkrequests.php", data: { id: user.id }, type: 'GET',
 						success: function(data) {
-							$("#state").load("./php/checkrequests.php?id=" + userid, function(response, status, xhr) {
+							$("#state").load("./php/checkrequests.php?id=" + user.id, function(response, status, xhr) {
 								console.log(response);
-								if (!mort) mort = check_requests(response, victimnom, victimid, userid);
+								if (!user.mort) user.mort = check_requests(response, user, victim);
 								else clearInterval(checking);
 							});
 						}});
diff --git a/php/request.php b/php/request.php
index 4b67dd6..1a34cdf 100644
--- a/php/request.php
+++ b/php/request.php
@@ -12,20 +12,25 @@
 	// Do the query
 	$query = "";
 	$query2 = "";
-	if ($_GET['msg'] == 1) $query = "UPDATE users SET requested=".$_GET['msg']." WHERE id=".$_GET['id']; // request kill
-	if ($_GET['msg'] == 2) $query = "UPDATE users SET requested=".$_GET['msg']." WHERE quimata=".$_GET['id']; // request dead
-	if ($_GET['msg'] == 3) {
-		$query = "UPDATE users SET mort=1 WHERE id=".$_GET['id']; // confirm dead/killed
-		$query2 = "UPDATE users SET requested=0 WHERE quimata=".$_GET['id']; // erase request from killer
+	if ($_GET['msg'] == "REQ KILL") $query = "UPDATE users SET requested=1 WHERE id=".(int)$_GET['victim_id']; // request kill
+	if ($_GET['msg'] == "REQ DEAD") $query = "UPDATE users SET requested=2 WHERE quimata=".(int)$_GET['user_id']; // request dead
+	if ($_GET['msg'] == "CONF DEAD") {
+		// User gets killed
+		$query = "UPDATE users SET requested=0, quimata=".(int)$_GET['user_quimata']." WHERE quimata=".$_GET['user_id']; // assign new victim to killer
+		$query2 = "UPDATE users SET quimata=0, mort=1 WHERE id=".(int)$_GET['user_id']; // confirm victim dead/killed
 	}
-	if ($_GET['msg'] == 4) $query = "UPDATE users SET requested=0 WHERE id=".$_GET['id']; // deny request
-
-	$a = "UPDATE users SET quimata=".$_GET['id']
+	if ($_GET['msg'] == "CONF KILL") {
+		// Victim gets killed
+		$query = "UPDATE users SET requested=0, quimata=".(int)$_GET['victim_quimata']." WHERE quimata=".$_GET['victim_id']; // assign new victim to killer
+		$query2 = "UPDATE users SET quimata=0, mort=1 WHERE id=".(int)$_GET['victim_id']; // confirm victim dead/killed
+	}
+	if ($_GET['msg'] == "DENY REQ") $query = "UPDATE users SET requested=0 WHERE id=".(int)$_GET['user_id']; // deny request
 
 	// Fetch the information of the user
-	if ($result = $conn->query($query)) echo $query;
+	if ($query != "" and $result = $conn->query($query)) echo $query;
 	else die("Wrong query: " . $query);
-	if ($result = $conn->query($query2)) echo "\n" . $query2;
+	if ($query2 != "" and $result = $conn->query($query2)) echo "\n" . $query2;
+	else echo "\nNo second query";
 
 	// Close connection
 	$conn->close();