Fully operational SQL
diff --git a/ajax/checkrequests.php b/ajax/checkrequests.php
new file mode 100644
index 0000000..fb6e9a6
--- /dev/null
+++ b/ajax/checkrequests.php
@@ -0,0 +1,14 @@
+<?php
+	require '../php/utils.php';
+	$user = get_users($_GET['id']);
+	
+	echo '{ ';
+	$first = true;
+	foreach ($user as $prop => $value) {
+		if (!$first) echo ', ';
+		else $first = false;
+		if ($prop == "nomcomplet") echo '"'.$prop.'": "'.$value.'"';
+		else echo '"'.$prop.'": '.$value;
+	}
+	echo ' }';
+?>
diff --git a/ajax/getusers.php b/ajax/getusers.php
new file mode 100644
index 0000000..cb8520d
--- /dev/null
+++ b/ajax/getusers.php
@@ -0,0 +1,5 @@
+<?php
+	require '../php/utils.php';
+	$users = get_users(0);
+	foreach ($users as $user) echo "<option value='".$user->id."'>".$user->nomcomplet."</option>\n";
+?>
diff --git a/ajax/victiminfo.php b/ajax/victiminfo.php
new file mode 100644
index 0000000..2396bb8
--- /dev/null
+++ b/ajax/victiminfo.php
@@ -0,0 +1,9 @@
+<?php
+	require '../php/utils.php';
+	$user = get_users($_GET['userid']);
+	$victim = get_users($user->quimata);
+?>
+
+<img width="300px" src="./imgs/<?=$victim->id?>.png" />
+<h2 id="victim_name"><?=$victim->nomcomplet?></h2>
+<h3><span id="victim_curs"><?=$victim->curs?></span>-<span id="victim_grau"><?=$victim->grau?></span></h3>
diff --git a/css/main.css b/css/main.css
index 8ba3b54..2e47813 100644
--- a/css/main.css
+++ b/css/main.css
@@ -18,4 +18,4 @@
 
 button#lose {
 	background-color: red;
-}
\ No newline at end of file
+}
diff --git a/index.php b/index.php
index 9f363ab..92c6850 100644
--- a/index.php
+++ b/index.php
@@ -22,7 +22,7 @@
 		</div>
 		
 		<script>
-			$.post("./php/getusers.php", function(data, status){
+			$.post("./ajax/getusers.php", function(data, status){
 				$("#list").html(data);
 			});
 		</script>
diff --git a/js/utils.js b/js/utils.js
index 228ffa4..42f720a 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -5,44 +5,52 @@
     return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
 };
 
-function send_request(user, victim, msg) {
+function send_request(user, msg) {
 	$.ajax({
 		'url': './php/request.php', 
 		'type': 'GET',
 		'contentType': 'application/json; charset=utf-8',
 		'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');
+			$.notify('Resposta guardada', 'success');
 			console.log(data);
+			
+			if (msg == 'CONF KILL' || msg == 'CONF DEAD') {
+				$(".victima").fadeOut(400, function() {
+					$(".victima").load('./ajax/victiminfo.php?userid=' + user.id);
+					$(".victima").fadeIn(400);
+				});
+			}
 		},
 		'error': function(xhr, status, error) { 
-			console.log('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024');
-			console.log(xhr.responseText);
+			$.notify('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024');
+			console.log(error);
 		}
 	});
 }
 
-function check_requests(requested, user, victim) {	
+function check_requests(info, user) {	
 	let dead = false;
-	let killed = false;
 	
-	if (requested != 0) {
+	if (info.requested) {
 		// 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 " + victim.nom + " ha dit que l'has matat, és veritat?");
-		
+		if(info.requested) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
+	
 		// Confirm/deny request
-		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
+		if (dead) send_request(user, "CONF DEAD"); // confirm death
+		else send_request(user, "DENY REQ"); // deny kill/death
 	}	
 
 	// Return mort
-	return dead;
+	return dead || info.mort;
+}
+
+function change_victim(user) {
+	$(".victima").fadeOut(400, function() {
+		$(".victima").load('./ajax/victiminfo.php?userid=' + user.id);
+		$(".victima").fadeIn(400);
+	});
 }
diff --git a/main.php b/main.php
index 5bf6765..820a18e 100644
--- a/main.php
+++ b/main.php
@@ -18,13 +18,11 @@
 				'id': <?=$user->id?>,
 				'quimata': <?=$user->quimata?>,
 				'requested': <?=$user->requested?>,
-				'mort': <?=$user->mort?>
-			};
-			
-			let victim = {
-				'id': <?=$victim->id?>,
-				'quimata': <?=$victim->quimata?>,
-				'nom': "<?=$victim->nom()?>"
+				'mort': <?=$user->mort?>,
+				
+				'nom': "<?=$user->nomcomplet?>",
+				'curs': <?=$user->curs?>,
+				'grau': <?=$user->grau?>
 			};
 		</script>
 	
@@ -43,23 +41,31 @@
 				</div>
 			</div>
 		</div>
-		<div id="butons">
-			<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 id="butons" class="options">
+			<button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
 		</div>
 		
 		<script>
 			$(document).ready(function() {
+				// Set interval of checking
 				let checking = setInterval(function() {
-					$.ajax({ url: "./php/checkrequests.php", data: { id: user.id }, type: 'GET',
-						success: function(data) {
-							$("#state").load("./php/checkrequests.php?id=" + user.id, function(response, status, xhr) {
-								console.log(response);
-								if (!user.mort) user.mort = check_requests(response, user, victim);
-								else clearInterval(checking);
-							});
-						}});
-				}, 1000);
+					$.ajax({
+						url: "./ajax/checkrequests.php",
+						data: { id: user.id },
+						type: 'GET',
+						success: function(response, status, xhr) {
+							let info = JSON.parse(response);
+							if (!user.mort) user.mort = check_requests(info, user);
+							else location.reload();
+														
+							if (info.quimata != user.quimata) {
+								change_victim(info);
+								user = info;
+							}
+							
+							console.log(response);
+					}});
+				}, 1500);
 			});
 		</script>
 	</body>
diff --git a/php/checkrequests.php b/php/checkrequests.php
deleted file mode 100644
index 4995ac4..0000000
--- a/php/checkrequests.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-	// Get the id
-	$id = $_GET['id'];
-	
-	// Define MySQL login variables
-	$servername = "localhost"; // "fdb22.awardspace.net";
-	$username = "root"; // "3155560_users";
-	$password = ""; // "btechnoro@fox4news.info";
-
-	// Create connection
-	$conn = new mysqli($servername, $username, $password, "pastanaga");
-	if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
-	$conn->set_charset("utf8");
-	
-	// Do the query
-	$query = "SELECT requested FROM users WHERE id=".$id;
-	$state = 0;
-
-	// Fetch the information of the user
-	if ($result = $conn->query($query)) {
-		while ($row = $result->fetch_row()) $state = $row[0];
-		$result->close();
-	} else {
-		die("Wrong query: " . $query);
-	}
-
-	// Close connection
-	$conn->close();
-	
-	// Print the state
-	echo $state;
-?>
diff --git a/php/getusers.php b/php/getusers.php
deleted file mode 100644
index b23c8c0..0000000
--- a/php/getusers.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-	// Define MySQL login variables
-	$servername = "localhost"; // "fdb22.awardspace.net";
-	$username = "root"; // "3155560_users";
-	$password = ""; // "btechnoro@fox4news.info";
-
-	// Create connection
-	$conn = new mysqli($servername, $username, $password, "pastanaga");
-	if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
-	$conn->set_charset("utf8");
-	
-	// Do the query
-	$query = "SELECT * FROM users";
-
-	// Fetch the information of the user
-	if ($result = $conn->query($query)) {
-		while ($row = $result->fetch_row()) {
-			$id = $row[0];
-			$nomcomplet = $row[1];
-			$curs = $row[2];
-			$grau = $row[3];
-			$quimata = $row[4];
-			
-			// Echo the options
-			echo "<option value='".$id."'>".$nomcomplet."</option>\n";
-		}
-		$result->close();
-	} else {
-		die("Wrong query: " . $query);
-	}
-
-	// Close connection
-	$conn->close();
-?>
diff --git a/php/login.php b/php/login.php
index 2dd713e..4dd5ee7 100644
--- a/php/login.php
+++ b/php/login.php
@@ -1,55 +1,6 @@
 <?php
-	class User{
-		public $id;
-		public $nomcomplet;
-		public $curs;
-		public $grau;
-		public $quimata;
-		
-		public function nom() {
-			$noms = explode(" ", $this->nomcomplet);
-			return $noms[0];
-		}
-	}
-	
-	function get_user($id) {
-		$user = new User();
-		
-		// Define MySQL login variables
-		$servername = "localhost"; // "fdb22.awardspace.net";
-		$username = "root"; // "3155560_users";
-		$password = ""; // "btechnoro@fox4news.info";
-
-		// Create connection
-		$conn = new mysqli($servername, $username, $password, "pastanaga");
-		if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
-		$conn->set_charset("utf8");
-		
-		// Do the query
-		$query = "SELECT * FROM users WHERE id=".$id;
-
-		// Fetch the information of the user
-		if ($result = $conn->query($query)) {
-			while ($row = $result->fetch_row()) {
-				$user->id = $row[0];
-				$user->nomcomplet = $row[1];
-				$user->curs = $row[2];
-				$user->grau = $row[3];
-				$user->quimata = $row[4];
-				$user->requested = $row[5];
-				$user->mort = $row[6];
-			}
-			$result->close();
-		} else {
-			die("Wrong query: " . $query);
-		}
-
-		// Close connection
-		$conn->close();
-		
-		return $user;
-	}
-	
-	$user = get_user($_GET['user']);
-	$victim = get_user($user->quimata);
+	require 'utils.php';
+	$user = get_users($_GET['user']);
+	$victim = get_users($user->quimata);
+	if ($user->mort) die("Puto mort de merda");
 ?>
diff --git a/php/request.php b/php/request.php
index 1a34cdf..ae4e3bb 100644
--- a/php/request.php
+++ b/php/request.php
@@ -12,18 +12,16 @@
 	// Do the query
 	$query = "";
 	$query2 = "";
-	if ($_GET['msg'] == "REQ KILL") $query = "UPDATE users SET requested=1 WHERE id=".(int)$_GET['victim_id']; // request kill
+	
+	$victimid = "ANY (SELECT quimata FROM users WHERE id=".(int)$_GET['user_id'].")";
+	
+	if ($_GET['msg'] == "REQ KILL") $query = "UPDATE users SET requested=1 WHERE id=".$victimid; // 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
+		$query = "UPDATE users SET requested=0, quimata=".(int)$_GET['user_quimata']." WHERE quimata=".(int)$_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'] == "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
diff --git a/php/utils.php b/php/utils.php
new file mode 100644
index 0000000..c6147fd
--- /dev/null
+++ b/php/utils.php
@@ -0,0 +1,58 @@
+<?php
+	class User{
+		public $id;
+		public $nomcomplet;
+		public $curs;
+		public $grau;
+		public $quimata;
+		
+		public function nom() {
+			$noms = explode(" ", $this->nomcomplet);
+			return $noms[0];
+		}
+	}
+	
+	function get_users($id = 0) {
+		$users = [];
+		
+		// Define MySQL login variables
+		$servername = "localhost"; // "fdb22.awardspace.net";
+		$username = "root"; // "3155560_users";
+		$password = ""; // "btechnoro@fox4news.info";
+
+		// Create connection
+		$conn = new mysqli($servername, $username, $password, "pastanaga");
+		if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
+		$conn->set_charset("utf8");
+		
+		// Do the query
+		$query = "SELECT * FROM users";
+		if ($id > 0) $query .= " WHERE id=".$id;
+
+		// Fetch the information of the user
+		if ($result = $conn->query($query)) {
+			while ($row = $result->fetch_row()) {
+				$user = new User();
+				
+				$user->id = $row[0];
+				$user->nomcomplet = $row[1];
+				$user->curs = $row[2];
+				$user->grau = $row[3];
+				$user->quimata = $row[4];
+				$user->requested = $row[5];
+				$user->mort = $row[6];
+				
+				array_push($users, $user);
+			}
+			$result->close();
+		} else {
+			die("Wrong query: " . $query);
+		}
+
+		// Close connection
+		$conn->close();
+		
+		if ($id > 0) return $users[0];
+		else return $users;
+	}
+?>