initial commit
This commit is contained in:
commit
0813dc21d8
13
admin_dashboard.php
Normal file
13
admin_dashboard.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Admin Bereich</h2>
|
||||
<p>Willkommen Admin <?php echo $_SESSION['username']; ?>!</p>
|
||||
|
||||
<a href="logout.php">Logout</a>
|
||||
64
champions_league.sql
Normal file
64
champions_league.sql
Normal file
@ -0,0 +1,64 @@
|
||||
-- Datenbank erstellen
|
||||
CREATE DATABASE IF NOT EXISTS champions_league
|
||||
CHARACTER SET utf8mb4
|
||||
COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE champions_league;
|
||||
|
||||
-- USERS (Login / Rollen)
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
user_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
role ENUM('admin','user') NOT NULL DEFAULT 'user'
|
||||
);
|
||||
|
||||
-- SEASONS (Saison)
|
||||
CREATE TABLE IF NOT EXISTS seasons (
|
||||
season_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL
|
||||
);
|
||||
|
||||
-- TEAMS (Teilnehmer)
|
||||
CREATE TABLE IF NOT EXISTS teams (
|
||||
team_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
country VARCHAR(50),
|
||||
group_name CHAR(1)
|
||||
);
|
||||
|
||||
-- PLAYERS (Spieler eines Teams)
|
||||
CREATE TABLE IF NOT EXISTS players (
|
||||
player_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
position VARCHAR(30),
|
||||
team_id INT NOT NULL,
|
||||
FOREIGN KEY (team_id) REFERENCES teams(team_id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- MATCHES (Spiele)
|
||||
CREATE TABLE IF NOT EXISTS matches (
|
||||
match_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
season_id INT NOT NULL,
|
||||
home_team_id INT NOT NULL,
|
||||
away_team_id INT NOT NULL,
|
||||
match_date DATE,
|
||||
FOREIGN KEY (season_id) REFERENCES seasons(season_id),
|
||||
FOREIGN KEY (home_team_id) REFERENCES teams(team_id),
|
||||
FOREIGN KEY (away_team_id) REFERENCES teams(team_id),
|
||||
CHECK (home_team_id <> away_team_id)
|
||||
);
|
||||
|
||||
-- GOAL_EVENTS (Tore + Assists)
|
||||
CREATE TABLE IF NOT EXISTS goal_events (
|
||||
goal_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
match_id INT NOT NULL,
|
||||
scorer_id INT NOT NULL,
|
||||
assist_id INT,
|
||||
minute INT NOT NULL,
|
||||
FOREIGN KEY (match_id) REFERENCES matches(match_id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (scorer_id) REFERENCES players(player_id),
|
||||
FOREIGN KEY (assist_id) REFERENCES players(player_id)
|
||||
);
|
||||
|
||||
|
||||
13
dashboard.php
Normal file
13
dashboard.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Willkommen <?php echo $_SESSION['username']; ?>!</h2>
|
||||
<p>Rolle: <?php echo $_SESSION['role']; ?></p>
|
||||
|
||||
<a href="logout.php">Logout</a>
|
||||
19
db.php
Normal file
19
db.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$host = "localhost";
|
||||
$db = "champions_league";
|
||||
$user = "root";
|
||||
$pass = "";
|
||||
$charset = "utf8mb4";
|
||||
|
||||
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
||||
|
||||
$options = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, $user, $pass, $options);
|
||||
} catch (PDOException $e) {
|
||||
die("Datenbankfehler: " . $e->getMessage());
|
||||
}
|
||||
17
login.php
Normal file
17
login.php
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login - CL Projekt</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Login</h2>
|
||||
|
||||
<form action="login_process.php" method="POST">
|
||||
Benutzername: <input type="text" name="username" required><br><br>
|
||||
Passwort: <input type="password" name="password" required><br><br>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
|
||||
<a href="register.php">Registrieren</a>
|
||||
</body>
|
||||
</html>
|
||||
31
login_process.php
Normal file
31
login_process.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
session_start();
|
||||
require 'db.php';
|
||||
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
$sql = "SELECT * FROM users WHERE username = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$username]);
|
||||
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password_hash'])) {
|
||||
|
||||
$_SESSION['user_id'] = $user['user_id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
$_SESSION['role'] = $user['role'];
|
||||
|
||||
// Rollenbasierte Weiterleitung
|
||||
if ($user['role'] === 'admin') {
|
||||
header("Location: admin_dashboard.php");
|
||||
} else {
|
||||
header("Location: dashboard.php");
|
||||
}
|
||||
exit();
|
||||
|
||||
} else {
|
||||
echo "Falscher Benutzername oder Passwort!";
|
||||
}
|
||||
?>
|
||||
6
logout.php
Normal file
6
logout.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
?>
|
||||
24
register.php
Normal file
24
register.php
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Registrieren - CL Projekt</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Registrierung</h2>
|
||||
|
||||
<form action="register_process.php" method="POST">
|
||||
Benutzername: <input type="text" name="username" required><br><br>
|
||||
Passwort: <input type="password" name="password" required><br><br>
|
||||
|
||||
Rolle:
|
||||
<select name="role">
|
||||
<option value="gast">Gast</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select><br><br>
|
||||
|
||||
<button type="submit">Registrieren</button>
|
||||
</form>
|
||||
|
||||
<a href="login.php">Zum Login</a>
|
||||
</body>
|
||||
</html>
|
||||
24
register_process.php
Normal file
24
register_process.php
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Registrieren - CL Projekt</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Registrierung</h2>
|
||||
|
||||
<form action="register_process.php" method="POST">
|
||||
Benutzername: <input type="text" name="username" required><br><br>
|
||||
Passwort: <input type="password" name="password" required><br><br>
|
||||
|
||||
Rolle:
|
||||
<select name="role">
|
||||
<option value="gast">Gast</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select><br><br>
|
||||
|
||||
<button type="submit">Registrieren</button>
|
||||
</form>
|
||||
|
||||
<a href="login.php">Zum Login</a>
|
||||
</body>
|
||||
</html>
|
||||
57
style.css
Normal file
57
style.css
Normal file
@ -0,0 +1,57 @@
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
font-family: Arial, sans-serif;
|
||||
background: radial-gradient(circle at top, #0a1a3f, #000814);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
width: 320px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 30px rgba(0,0,0,0.6);
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 100px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #fff;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background: #1e90ff;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: #d3d7dd;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #ff6b6b;
|
||||
margin-top: 15px;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user