diff --git a/app/getuserdata.php b/app/getuserdata.php new file mode 100644 index 0000000..dc2dedc --- /dev/null +++ b/app/getuserdata.php @@ -0,0 +1,24 @@ +id = $id; + $this->mysqlConnection = $mysqlConnection; + } + + public function getData() + { + $command = "SELECT * FROM `userdata` WHERE `userid` LIKE '$this->id';"; + $res = mysqli_query($this->mysqlConnection, $command); + return mysqli_fetch_array($res)[1]; + } + + +} \ No newline at end of file diff --git a/app/getuserid.php b/app/getuserid.php new file mode 100644 index 0000000..a9d1025 --- /dev/null +++ b/app/getuserid.php @@ -0,0 +1,26 @@ +username = $username; + $this->mysqlConnection = $mysqlConnection; + } + + public function getID() + { + $command = "SELECT * FROM `useraccounts` WHERE `username` LIKE '$this->username';"; + $res = mysqli_query($this->mysqlConnection, $command); + $useraccountsDB = mysqli_fetch_array($res); + return $useraccountsDB[0]; + + } + + +} \ No newline at end of file diff --git a/app/register.php b/app/register.php index 2488ef5..60e5470 100644 --- a/app/register.php +++ b/app/register.php @@ -22,4 +22,19 @@ public function newUser() return $this->mysqlconnection->query("INSERT INTO `useraccounts` (`ID`, `username`, `password`, `email`) VALUES (NULL, '$this->name', '$createHashPassword', '$this->email')"); } + public function newUser2() + { + $createHashPassword = password_hash($this->password, PASSWORD_DEFAULT); + return $this->mysqlconnection->query("INSERT INTO `useraccounts` (`ID`, `username`, `password`, `email`) VALUES (NULL, '$this->name', '$createHashPassword', '$this->email');"); + + $this->getID($this->name, $this->mysqlconnection); + + + // wir brauchen die ID um ein neues Space zu erstellen + //-> Space erstellen + + } + +// Beim registieren muss eine neue Space eingerichtet werden! + } \ No newline at end of file diff --git a/app/test.php b/app/test.php new file mode 100644 index 0000000..a29b324 --- /dev/null +++ b/app/test.php @@ -0,0 +1,33 @@ +query("SELECT `Username` FROM `Accounts` ORDER BY RAND() LIMIT 5;"); +$clickTest = "No button has been clicked"; +if (isset($_POST["showAllSort"])) { + $entries = $db->query("SELECT `Username` FROM `Accounts` ORDER BY RAND();"); + $clickTest = "Show all button has been clicked"; + +} elseif (isset($_POST["alphabetSort"])) { + $entries = $db->query("SELECT `Username` FROM `Accounts` ORDER BY ASC;"); + $clickTest = "Sort by Alphabet has been clicked"; +} + +echo $clickTest; + +while ($row = $entries->fetch_assoc()){ +?> + +

Other players

+ + + +
+

+ +

+

+ +
+
+ +
\ No newline at end of file diff --git a/src/privateSpace.php b/src/privateSpace.php index f47efee..d51ef92 100644 --- a/src/privateSpace.php +++ b/src/privateSpace.php @@ -1,53 +1,37 @@ getID(); +echo $id; - - - - - - -$username = $_SESSION['username']; -$query = "SELECT * FROM `useraccounts` WHERE `username` LIKE '$username'"; -$result = mysqli_query($mysqli, $query); -$check = mysqli_fetch_array($result); -echo $check[0]; // nun habe ich die id - -$id = $check[0]; - -$new = "SELECT * FROM `userdata` WHERE `userid` LIKE '$id';"; -$res = mysqli_query($mysqli, $new); -$update = mysqli_fetch_array($res); -echo "
User daten:"; -echo $update[1]."
"; -$oldData = $update[1]; +$userdata = (new getuserdata($id, $mysqli))->getData(); +echo $userdata; if(isset($_POST['upload'])){ - $newdata = $_POST['text']; - $command = "UPDATE `userdata` SET `data` = '$oldData''$newdata' WHERE `userdata`.`userid` = $id"; - return $mysqli->query($command); + // INSERT INTO userdata (userid, data) VALUES ('12', 'sfff'); + $command = "UPDATE `userdata` SET `data` = $newdata WHERE `userdata`.`userid` = $id"; + $mysqli->query($command); }