Anmeldefunktion + kleine Änderungen
This commit is contained in:
parent
1c292db602
commit
72c24719de
4 changed files with 32 additions and 6 deletions
20
angemeldet.php
Normal file
20
angemeldet.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (isset($_SESSION['user'])) {
|
||||
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
|
||||
echo "Hallo " . $_SESSION['user'] . " - <a href='" . $url . "?abmelden=1'>Abmelden</a>";
|
||||
|
||||
}else {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function FensterOeffnen (Adresse) {
|
||||
MeinFenster = window.open(Adresse, "Zweitfenster", "width=300,height=400,left=100,top=200");
|
||||
MeinFenster.focus();
|
||||
}
|
||||
</script>
|
||||
<p class="hover">Du bist nicht angemeldet - <a href="./login.php" onclick="FensterOeffnen(this.href); return false">Anmelden</a></p>
|
||||
<?php
|
||||
}
|
||||
if (isset($_GET["abmelden"])) {unset($_SESSION['user']);}
|
||||
|
||||
?>
|
12
login.php
12
login.php
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
session_start();
|
||||
if (isset($_POST["benutzername"])) {
|
||||
require_once "verbindungsaufbau.php"; //mit Server verbinden
|
||||
$user= $_POST["benutzername"];
|
||||
|
@ -12,9 +13,7 @@ if (isset($_POST["benutzername"])) {
|
|||
$stmt->bind_result($password_db);
|
||||
$stmt->fetch();
|
||||
if($password_db == $password_hash) {
|
||||
echo "Hallo $user";
|
||||
$richtig="yes";
|
||||
setcookie("angemeldet", $user);
|
||||
$_SESSION['user'] = $user;
|
||||
} else {
|
||||
echo "falsches Passwort";
|
||||
}
|
||||
|
@ -24,7 +23,7 @@ if (isset($_POST["benutzername"])) {
|
|||
}
|
||||
$mysqli->close();
|
||||
}
|
||||
if (!isset($richtig) || $richtig != "yes") {
|
||||
if (!isset($_SESSION['user'])) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
@ -46,8 +45,11 @@ if (!isset($richtig) || $richtig != "yes") {
|
|||
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo "Hallo " . $_SESSION['user'] . " - <a href='./login.php?abmelden=1'>Abmelden</a>";
|
||||
echo "<script>window.opener.parent.location.reload();window.close();</script>";
|
||||
}
|
||||
|
||||
if (isset($_GET["abmelden"])) {unset($_SESSION['user']);}
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ if (isset($_POST["name"])) { //Wenn das Formular ausgefüllt wurde ...
|
|||
$stadt = $_POST["stadt"];
|
||||
$strasse = $_POST["strasse"];
|
||||
$hausnummer = $_POST["hausnummer"];
|
||||
if ($stmt = $mysqli->prepare("INSERT INTO orte (ort_name, stadt, plz, strasse, hausnummer) VALUES (?, ?, ?, ?, ?)")) { // Der SQL-Befehl wirdvorbereitet ...
|
||||
if ($stmt = $mysqli->prepare("INSERT INTO orte (ort_name, stadt, plz, strasse, hausnummer) VALUES (?, ?, ?, ?, ?)")) { // Der SQL-Befehl wird vorbereitet ...
|
||||
$stmt->bind_param("sssss", $name, $stadt, $plz, $strasse, $hausnummer); // ... eingesetzt ...
|
||||
$stmt->execute(); // ... und ausgeführt
|
||||
$stmt->close();
|
||||
|
|
|
@ -11,12 +11,16 @@
|
|||
}
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once "angemeldet.php";
|
||||
require_once "verbindungsaufbau.php"; //mit Server verbinden
|
||||
|
||||
|
||||
|
||||
$ergebnis = $mysqli->query("SELECT * FROM orte, veranstaltungen WHERE orte.ort_id = veranstaltungen.ort_id"); //SQL Befehl ausführen
|
||||
echo "<table border='1'>\n";
|
||||
echo "<tr><th>Veranstaltungsname</th><th>Beschreibung</th><th>Zeit</th><th>Ort</th><th>Adresse</th><th>Ändern</th><th>Löschen</th>"; //Zeile mit Überschriften
|
||||
|
|
Reference in a new issue