94 lines
3.0 KiB
PHP
94 lines
3.0 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['username'])) {
|
|
$_SESSION['msg'] = "Bitte zuerst einloggen.";
|
|
}
|
|
if (isset($_GET['logout'])) {
|
|
session_destroy();
|
|
unset($_SESSION['username']);
|
|
header("location: index.php");
|
|
}
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="de" dir="ltr">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
<meta name="author" content="Victor Giers"/>
|
|
<meta name="created" content="2019-01-10"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Direkter Tausch - Online Platform für das Repair Café</title>
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="header">
|
|
<h2>Direkter Tausch - Online Platform für das Repair Café</h2>
|
|
</div>
|
|
<div class="content">
|
|
<!-- notification message -->
|
|
<?php if (isset($_SESSION['success'])) : ?>
|
|
<div class="error success" >
|
|
<h3>
|
|
<?php
|
|
echo $_SESSION['success'];
|
|
unset($_SESSION['success']);
|
|
?>
|
|
</h3>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<!-- logged in user information -->
|
|
<?php
|
|
|
|
|
|
$db_server = '';
|
|
$db_user = '';
|
|
$db_password = '';
|
|
$db_name = '';
|
|
$user_table = '';
|
|
$entry_table = '';
|
|
$conn = new mysqli($db_server, $db_user, $db_password, $db_name);
|
|
$conn->set_charset("utf8");
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
if (isset($_SESSION['username'])){
|
|
echo "<p>Sie sind eingeloggt als: <strong>" . $_SESSION['username'] . "</strong></p>
|
|
<p> <a href='index.php?logout=1' style='color: red;''>Ausloggen</a><br><br></p>
|
|
<p> <a href='newentry.php'>Neuer Eintrag</a><br><br></p>";
|
|
|
|
} else {
|
|
echo "<p>Um Einträge zu verfassen, <strong><a href='register.php'>registrieren Sie sich</a></strong> oder <strong><a href='login.php'>loggen Sie sich ein</a></strong>.</p>
|
|
<br><br>";
|
|
}
|
|
|
|
|
|
$entries = "SELECT $entry_table.*, $user_table.username, $user_table.email FROM $entry_table INNER JOIN $user_table ON $entry_table.user = $user_table.id ORDER BY $entry_table.id DESC";
|
|
|
|
$result = $conn->query($entries);
|
|
if ($result->num_rows > 0) {
|
|
echo "<table id='entries'>\n<tr>\n<th>Datum</th><th>Name</th><th>Bietet an</th><th>Möchte dafür</th><th>Kontakt</th>\n</tr>\n";
|
|
|
|
while($row = $result->fetch_assoc()) {
|
|
echo "<tr>\n";
|
|
echo "<td id='date'><div class='tablediv'>" . date("d.m.Y", strtotime($row["date"])) . "</div></td><td id='username'><div class='tablediv'>" . $row["username"] . "</div></td><td id='does'><div class='tablediv'>" . $row["does"] . "</div></td><td id='wants'><div class='tablediv'>" . $row["wants"] . "</div></td><td id='email'><div class='tablediv'><a href='mailto:" . $row["email"] . "'>" . $row["email"] . "</a></div>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
echo("</table>\n");
|
|
} else {
|
|
echo "Keine Einträge vorhanden.\n";
|
|
}
|
|
|
|
|
|
/*----*/
|
|
|
|
$conn->close();
|
|
?>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|