changed config.php and added delete function for administrator
This commit is contained in:
parent
99535db4ee
commit
a121e53503
10 changed files with 21 additions and 20 deletions
|
|
@ -6,5 +6,7 @@ return [
|
||||||
'port' => 3306,
|
'port' => 3306,
|
||||||
'dbname' => 'MatheApp',
|
'dbname' => 'MatheApp',
|
||||||
'charset' => 'utf8mb4'
|
'charset' => 'utf8mb4'
|
||||||
]
|
],
|
||||||
|
'username' => 'MatheApp',
|
||||||
|
'password' => 'password'
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "Delete";
|
$heading = "Delete";
|
||||||
$username = "MatheApp";
|
|
||||||
$password = "password";
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$db->delete($_SESSION['username']);
|
$db->delete($_SESSION['username']);
|
||||||
|
|
|
||||||
9
controllers/deleteUser.php
Normal file
9
controllers/deleteUser.php
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
$config = require('config.php');
|
||||||
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
if (isset($_POST['delete'])){
|
||||||
|
$db->delete($_POST['username']);
|
||||||
|
header("Location: /profile");
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "Game";
|
$heading = "Game";
|
||||||
$username = 'MatheApp';
|
|
||||||
$password = 'password';
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
session_start();
|
session_start();
|
||||||
if(!isset($_SESSION["username"])){
|
if(!isset($_SESSION["username"])){
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "Login";
|
$heading = "Login";
|
||||||
$username = "MatheApp";
|
|
||||||
$password = "password";
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
|
|
||||||
if (isset($_POST["submit"])) {
|
if (isset($_POST["submit"])) {
|
||||||
$db->login([$_POST["username"], $_POST["password"]]);
|
$db->login([$_POST["username"], $_POST["password"]]);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "profile";
|
$heading = "profile";
|
||||||
$username = "MatheApp";
|
|
||||||
$password = "password";
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
if(!isset($_SESSION["username"])){
|
if(!isset($_SESSION["username"])){
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
$heading = "Register";
|
$heading = "Register";
|
||||||
require 'Validator.php';
|
require 'Validator.php';
|
||||||
$username = 'MatheApp';
|
|
||||||
$password = 'password';
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
|
|
||||||
if (isset($_POST["submit"])) {
|
if (isset($_POST["submit"])) {
|
||||||
$db->register($_POST);
|
$db->register($_POST);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$username = 'MatheApp';
|
|
||||||
$password = 'password';
|
|
||||||
$config = require('config.php');
|
$config = require('config.php');
|
||||||
$db = new Database($config['database'], $username, $password);
|
$db = new Database($config['database'], $config['username'], $config['password']);
|
||||||
$data = json_decode(file_get_contents("php://input"), true);
|
$data = json_decode(file_get_contents("php://input"), true);
|
||||||
$db->query("UPDATE user SET level= :level, xp= :xp, coins= :coins WHERE username = :user", [
|
$db->query("UPDATE user SET level= :level, xp= :xp, coins= :coins WHERE username = :user", [
|
||||||
"level" => $data["level"],
|
"level" => $data["level"],
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ return[
|
||||||
'/profile' => 'controllers/profile.php',
|
'/profile' => 'controllers/profile.php',
|
||||||
'/logout' => 'controllers/logout.php',
|
'/logout' => 'controllers/logout.php',
|
||||||
'/delete' => 'controllers/delete.php',
|
'/delete' => 'controllers/delete.php',
|
||||||
'/updateData' => 'controllers/updateData.php'
|
'/updateData' => 'controllers/updateData.php',
|
||||||
|
'/deleteUser' => 'controllers/deleteUser.php'
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@
|
||||||
echo "<th>". $user['username'] ."</th>";
|
echo "<th>". $user['username'] ."</th>";
|
||||||
echo "<th>". $user['email'] ."</th>";
|
echo "<th>". $user['email'] ."</th>";
|
||||||
echo "<th>". $user['level'] ."</th>";
|
echo "<th>". $user['level'] ."</th>";
|
||||||
|
echo '<th><form method="POST" action="/deleteUser"><input name="username" type="hidden" value="'.$user['username'].'"><input type="submit" name="delete" value="Loeschen"></form></th>';
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue