Merge pull request #1 from avm99963/polishcss
Perfeccionament del disseny
diff --git a/ajax/getusers.php b/ajax/getusers.php
index 2f36f84..30e6657 100644
--- a/ajax/getusers.php
+++ b/ajax/getusers.php
@@ -1,4 +1,4 @@
-<option>Selecciona usuari...</option>
+<option selected disabled hidden>Selecciona usuari...</option>
<?php
require '../credentials.php';
diff --git a/index.php b/index.php
index f770c9b..16378a9 100644
--- a/index.php
+++ b/index.php
@@ -28,6 +28,14 @@
<script>
$.post("./ajax/getusers.php", function(data, status){
$("#list").html(data);
+
+ userid = <?=isset($_COOKIE['user']) ? $_COOKIE['user'] : -1 ?>;
+ username = $('option[value=' + userid + ']').text();
+
+ if (userid > 0) {
+ redir = confirm("Has entrat com a usuari " + username + " anteriorment, vols tornar-ho a fer?");
+ if (redir) window.location.href = 'main.php';
+ }
});
$('select').on('change', function() {
diff --git a/php/request.php b/php/request.php
index 58201ae..12f0f7d 100644
--- a/php/request.php
+++ b/php/request.php
@@ -4,7 +4,7 @@
// Do the query
$queries = [""];
- $victimid = "ANY (SELECT quimata FROM users WHERE id=".(int)$_POST['user_id'].")";
+ $victimid = "ANY (SELECT quimata FROM (SELECT * FROM users) AS victims WHERE id=".(int)$_POST['user_id'].")";
if ($_POST['msg'] == "REQ KILL") $queries = ["UPDATE users SET requested=1 WHERE id=".$victimid]; // request kill
if ($_POST['msg'] == "REQ DEAD") $queries = ["UPDATE users SET requested=2 WHERE quimata=".(int)$_POST['user_id']]; // request dead
@@ -16,6 +16,6 @@
// Fetch the information of the user
foreach ($queries as $query) {
if ($query != "" and $result = query($query)) echo $query;
- else die("Wrong query: " . $query);
+ else die("Query failed: " . $result);
}
?>
diff --git a/php/utils.php b/php/utils.php
index ae0cb5b..1e20ebf 100644
--- a/php/utils.php
+++ b/php/utils.php
@@ -20,7 +20,7 @@
$conn->set_charset("utf8");
// Execute query and save result
- $result = $conn->query($query);
+ if (!$result = $conn->query($query)) $result = $conn->error;
// Close the connection
$conn->close();
@@ -54,7 +54,7 @@
}
$result->close();
} else {
- die("Wrong query: " . $query);
+ die("Query failed: " . $query);
}
if ($id > 0) return $users[0];