Missatges dinĂ nimcs funcionant correctament
diff --git a/js/utils.js b/js/utils.js
index 7ed6897..ec42a8a 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -12,9 +12,9 @@
'contentType': 'application/json; charset=utf-8',
'data': { 'id': id, 'msg': msg },
'success': function(data) {
- console.log('Success');
if (msg <= 2) $.notify('Confirmació enviada', 'success');
else $.notify('Resposta guardada', 'success');
+ console.log(data);
},
'error': function(xhr, status, error) {
console.log('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024');
@@ -38,6 +38,6 @@
else send_request(userid, 4); // deny kill/death
}
- // Reset
- return requested = 0;
+ // Return mort
+ return dead;
}
diff --git a/main.php b/main.php
index cf88aa9..298753a 100644
--- a/main.php
+++ b/main.php
@@ -27,7 +27,7 @@
<div id="inner-container">
<h2>Hola <name id="user_name"><?=$user->nom()?></name>,</h2>
<h3>La teva víctima és:</h3>
- <div style="display:none;" id="state">0</div>
+ <div id="state">0</div>
<div class="victima">
<img width="300px" src="./imgs/<?=$victim->id?>.png" />
@@ -47,7 +47,8 @@
$.ajax({ url: "./php/checkrequests.php", data: { id: userid }, type: 'GET',
success: function(data) {
$("#state").load("./php/checkrequests.php?id=" + userid, function(response, status, xhr) {
- if (!mort) requested = check_requests(response, victimnom, victimid, userid);
+ console.log(response);
+ if (!mort) mort = check_requests(response, victimnom, victimid, userid);
else clearInterval(checking);
});
}});
diff --git a/php/request.php b/php/request.php
index 3ff9b5a..883d9b2 100644
--- a/php/request.php
+++ b/php/request.php
@@ -11,14 +11,19 @@
// 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
+ 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'] == 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!';
+ if ($result = $conn->query($query)) echo $query;
else die("Wrong query: " . $query);
+ if ($result = $conn->query($query2)) echo "\n" . $query2;
// Close connection
$conn->close();