DB funciona perfectament
diff --git a/db/connect.php b/db/connect.php
deleted file mode 100644
index 0da9b3f..0000000
--- a/db/connect.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
- // Define MySQL login variables
- $servername = "fdb22.awardspace.net";
- $username = "3155560_users";
- $password = "btechnoro@fox4news.info";
-
- // Create connection
- $conn = new mysqli($servername, $username, $password, "3155560_users");
- if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
- $conn->set_charset("utf8");
-?>
diff --git a/db/fetch.php b/db/fetch.php
deleted file mode 100644
index eddd5dd..0000000
--- a/db/fetch.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
- if ($result = $conn->query($query)) {
-
- // Fetch the information of the user
- 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];
- }
-
- $result->close();
- } else {
- echo "Wrong query";
- }
-?>
diff --git a/js/utils.js b/js/utils.js
index 5886883..b4f139a 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -12,6 +12,6 @@
'dataType': 'json',
'data': { 'id': id, 'msg': msg },
'success': function(data) { console.log('Success'); },
- 'error': function(xhr, status, error) {}
+ 'error': function(xhr, status, error) { alert('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024'); console.log(xhr); }
});
}
diff --git a/main.php b/main.php
index bd0cedb..960197b 100644
--- a/main.php
+++ b/main.php
@@ -4,22 +4,28 @@
<title>Pàgina de l'usuari</title>
<link rel="stylesheet" href="./css/basic.css" />
<link rel="stylesheet" href="./css/main.css" />
-
- <script src="./js/utils.js"></script>
+
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
+ <script src="./js/utils.js"></script>
<?php require 'login.php'; ?>
<script>
- if (<?=$user->mort?>) document.write("Venga niño, pitjor que el Condom, MORT.");
- else {
- let dead = false
- let killed = false
+ if (<?=$user->mort?>) {
+ // User is dead
+ document.write("Venga niño, pitjor que el Condom, MORT.");
+ } else {
+ let dead = false;
+ let killed = false;
+
+ // Check for requests
if(<?=$user->requested?> == 1) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
if(<?=$user->requested?> == 2) killed = confirm("En/na <?=$victim->nom()?> ha dit que l'has matat, és veritat?");
+
+ // Confirm/deny request
if (dead) send_request(<?=$user->id?>, 3); // confirm death
- else send_request(<?=$user->id?>, 5); // deny death
- if (killed) send_request(<?=$victim->id?>, 4); // confirm kill
- else send_request(<?=$user->id?>, 5); // deny kill
+ else send_request(<?=$user->id?>, 4); // deny death
+ if (killed) send_request(<?=$victim->id?>, 3); // confirm kill
+ else send_request(<?=$user->id?>, 4); // deny kill
}
</script>
</head>
diff --git a/request.php b/request.php
index a26e445..cc16327 100644
--- a/request.php
+++ b/request.php
@@ -13,9 +13,8 @@
$query = "";
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
- if ($_GET['msg'] == 4) $query = "UPDATE users SET mort=1 WHERE quimata=".$_GET['id']; // confirm killed
- if ($_GET['msg'] == 5) $query = "UPDATE users SET requested=0 WHERE id=".$_GET['id']; // deny request
+ if ($_GET['msg'] == 3) $query = "UPDATE users SET mort=1 WHERE id=".$_GET['id']; // confirm dead/killed
+ if ($_GET['msg'] == 4) $query = "UPDATE users SET requested=0 WHERE id=".$_GET['id']; // deny request
// Fetch the information of the user
if ($result = $conn->query($query)) echo 'Success!';