implemented logout

This commit is contained in:
Marcel Schwarz 2018-06-17 22:23:11 +02:00
parent 2c5df120cb
commit 41829bbbf0
6 changed files with 64 additions and 138 deletions

View File

@ -1,72 +0,0 @@
<?php
if(isset($_POST['tan'])){
//echo "Tan ->" . $_POST['tan'] . "<-";
if($_POST['tan'] != ""){
addEntry();
consumeTan($_POST['tan']);
}
}
function addEntry() {
}
function consumeTan($tan) {
require('dbConnect.php'); //Erstellt variable mit dem namen $database
//Stelle sicher dass die Tan noch verfügbar ist.
$abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `tan` = '" . $tan . "'";
$ergebnis = mysqli_query($database, $abfrage);
if($ergebnis->num_rows == 0){
echo "Tan nicht vergeben";
return;
}
$resultStr = "";
while ($row = $ergebnis->fetch_assoc()) {
$resultStr = $resultStr . $row["used"] . ' ' . $row["tan"] . '<br>';
if($row["used"] == 1){
echo "Tan schon verbraucht";
return;
}
}
//echo $resultStr;
//Setzte Tan auf verbraucht
$update = $database->query("UPDATE `tans` SET `used`= true WHERE `tan` = '" . $_POST['tan'] . "'");
echo "Tan verbraucht " . $_POST['tan'];
}
?>
<!doctype html>
<html lang="en">
<head>
<script src="js/entry.js"></script>
</head>
<body>
<form id="entry-form" action="entry.php" method="post">
Vorname:<br>
<input type="text" name="vorname"><br>
Nachname:<br>
<input type="text" name="nachname"><br>
E-Mail:<br>
<input type="text" name="email"><br>
Nachricht:<br>
<input type="text" name="eintrag"><br>
Tan:<br>
<input type="text" name="tan"><br>
<input id="absenden" type="submit" value="Abschicken">
<button type="reset">Loeschen</button>
</form>
</body>
</html>

View File

@ -18,67 +18,54 @@
<body> <body>
<!-- Include the header--> <!-- Include the header-->
<?php <?php
if(isset($_SESSION['user'])){ if(isset($_SESSION['user'])){
include('segments/_headerSession.php'); include('segments/_headerSession.php');
} else { } else {
include('segments/_header.php'); include('segments/_header.php');
} }
?> ?>
<?php #include('segments/_indexTestLoginVals.php'); ?><!-- For forms testing --> <?php #include('segments/_indexTestLoginVals.php'); ?><!-- For forms testing -->
<!-- Welche seite soll geladen werden-->
<?php <?php
$page = '_404.html'; $page = '_404.html';
$p = ''; $p = '';
if(isset($_GET['page'])){$p = $_GET['page'];} if(isset($_GET['page'])){$p = $_GET['page'];}
if($p == '' || $p == 'home'){ if($p == '' || $p == 'home'){
$page = '_home.php'; $page = '_home.php';
}
if($p == 'newEntry'){
$page = '_entryForm.php';
}
if($p == 'myFriendsBook'){
$page = '_myFriendsBook.php';
}
if($p == 'login'){
if(isset($_SESSION['user'])){
header('Location: index.php');
} else {
$page = '_login.php';
} }
}
if($p == 'register'){ if($p == 'newEntry'){
$page = '_register.php'; $page = '_entryForm.php';
} }
require('segments/'.$page); if($p == 'myFriendsBook'){
$page = '_myFriendsBook.php';
}
if($p == 'login'){
if(isset($_SESSION['user'])){
header('Location: index.php');
} else {
$page = '_login.php';
}
}
if($p == 'register'){
$page = '_register.php';
}
require('segments/'.$page);
?> ?>
<div id="content"> <div id="content">
<br><span> Session User: <?php echo $_SESSION['user']; ?> </span> <br><span> Session User: <?php echo $_SESSION['user']; ?> </span>
</div> </div>
<!-- Zum testen der Daten die ueber die Modals reinkommen -->
<!-- Include the footer--> <!-- Include the footer-->
<?php include('segments/_footer.html'); ?> <?php include('segments/_footer.html'); ?>

5
php/logout.php Normal file
View File

@ -0,0 +1,5 @@
<?php
session_start();
session_destroy();
header('Location: ../index.php');
?>

View File

@ -50,7 +50,7 @@ function consumeTan($tanID) {
</div> </div>
<hr /> <hr />
<form id="entry-form" action="index.php" method="post"> <form id="entry-form" action="index.php?page=newEntry" method="post">
<!-- Vorname--> <!-- Vorname-->
<div class="input-group input-group-sm mb-3"> <div class="input-group input-group-sm mb-3">
<div class="input-group-prepend"> <div class="input-group-prepend">

View File

@ -1,3 +1,5 @@
<div> <div>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel"> <div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" style="height: 100px;"> <div class="carousel-inner" style="height: 100px;">
@ -36,7 +38,11 @@
<form class="form-inline my-2 my-lg-0"> <form class="form-inline my-2 my-lg-0">
<div class="btn-group" role="group" aria-label="Basic example"> <div class="btn-group" role="group" aria-label="Basic example">
<!-- Button Logout --> <!-- Button Logout -->
<button type="button" class="btn btn-secondary">Logout</button> <!-- <button id="btnLogout" onclick=window.location.href = 'http://www.google.com' type="button" class="btn btn-secondary">Logout</button> -->
<form action="" method="post">
<input class="btn btn-secondary" onClick="window.location.href = 'php/logout.php'" type="button" value="Logout"></input>
</form>
</div> </div>
</form> </form>
</div> </div>

View File

@ -4,27 +4,27 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` (
`tanID` INT NOT NULL , `tanID` INT NOT NULL ,
`vorname` LONGTEXT NOT NULL , `vorname` LONGTEXT NOT NULL ,
`nachname` LONGTEXT NOT NULL , `nachname` LONGTEXT NOT NULL ,
`geburtstag` LONGTEXT NOT NULL , `geburtstag` LONGTEXT DEFAULT NULL ,
`wohnort` LONGTEXT NOT NULL , `wohnort` LONGTEXT DEFAULT NULL ,
`strasse` LONGTEXT NOT NULL , `strasse` LONGTEXT DEFAULT NULL ,
`kennenUns` LONGTEXT NOT NULL , `kennenUns` LONGTEXT NOT NULL ,
`festnetz` LONGTEXT NOT NULL , `festnetz` LONGTEXT DEFAULT NULL ,
`handynummer` LONGTEXT NOT NULL , `handynummer` LONGTEXT DEFAULT NULL ,
`email` LONGTEXT NOT NULL , `email` LONGTEXT NOT NULL ,
`hobbies` LONGTEXT NOT NULL , `hobbies` LONGTEXT DEFAULT NULL ,
`berufswunsch` LONGTEXT NOT NULL , `berufswunsch` LONGTEXT DEFAULT NULL ,
`essen` LONGTEXT NOT NULL , `essen` LONGTEXT DEFAULT NULL ,
`insel` LONGTEXT NOT NULL , `insel` LONGTEXT DEFAULT NULL ,
`film` LONGTEXT NOT NULL , `film` LONGTEXT DEFAULT NULL ,
`sport` LONGTEXT NOT NULL , `sport` LONGTEXT DEFAULT NULL ,
`charakter` LONGTEXT NOT NULL , `charakter` LONGTEXT DEFAULT NULL ,
`tier` LONGTEXT NOT NULL , `tier` LONGTEXT DEFAULT NULL ,
`musik` LONGTEXT NOT NULL , `musik` LONGTEXT DEFAULT NULL ,
`game` LONGTEXT NOT NULL , `game` LONGTEXT DEFAULT NULL ,
`alk` LONGTEXT NOT NULL , `alk` LONGTEXT DEFAULT NULL ,
`story` LONGTEXT NOT NULL , `story` LONGTEXT DEFAULT NULL ,
`absturz` LONGTEXT NOT NULL , `absturz` LONGTEXT DEFAULT NULL ,
`trinkspiel` LONGTEXT NOT NULL , `trinkspiel` LONGTEXT DEFAULT NULL ,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`tanID`)) ENGINE = InnoDB; UNIQUE (`tanID`)) ENGINE = InnoDB;