Separació codis php
diff --git a/php/getusers.php b/php/getusers.php
new file mode 100644
index 0000000..f3f79e9
--- /dev/null
+++ b/php/getusers.php
@@ -0,0 +1,34 @@
+<?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");
+
+ // 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
new file mode 100644
index 0000000..ee64f27
--- /dev/null
+++ b/php/login.php
@@ -0,0 +1,56 @@
+<?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 = "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");
+
+ // 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->quielmata = $row[5];
+ $user->requested = $row[6];
+ $user->mort = $row[7];
+ }
+ $result->close();
+ } else {
+ die("Wrong query: " . $query);
+ }
+
+ // Close connection
+ $conn->close();
+
+ return $user;
+ }
+
+ $user = get_user($_GET['user']);
+ $victim = get_user($user->quimata);
+?>
diff --git a/php/request.php b/php/request.php
new file mode 100644
index 0000000..cc16327
--- /dev/null
+++ b/php/request.php
@@ -0,0 +1,25 @@
+<?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");
+
+ // Do the query
+ $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/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!';
+ else die("Wrong query: " . $query);
+
+ // Close connection
+ $conn->close();
+?>