implemented logout
This commit is contained in:
parent
2c5df120cb
commit
41829bbbf0
72
entry.php
72
entry.php
@ -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>
|
77
index.php
77
index.php
@ -18,67 +18,54 @@
|
||||
|
||||
<body>
|
||||
<!-- Include the header-->
|
||||
|
||||
<?php
|
||||
if(isset($_SESSION['user'])){
|
||||
include('segments/_headerSession.php');
|
||||
} else {
|
||||
include('segments/_header.php');
|
||||
}
|
||||
|
||||
|
||||
if(isset($_SESSION['user'])){
|
||||
include('segments/_headerSession.php');
|
||||
} else {
|
||||
include('segments/_header.php');
|
||||
}
|
||||
?>
|
||||
|
||||
<?php #include('segments/_indexTestLoginVals.php'); ?><!-- For forms testing -->
|
||||
|
||||
<!-- Welche seite soll geladen werden-->
|
||||
<?php
|
||||
$page = '_404.html';
|
||||
$p = '';
|
||||
if(isset($_GET['page'])){$p = $_GET['page'];}
|
||||
$page = '_404.html';
|
||||
$p = '';
|
||||
if(isset($_GET['page'])){$p = $_GET['page'];}
|
||||
|
||||
if($p == '' || $p == 'home'){
|
||||
$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 == '' || $p == 'home'){
|
||||
$page = '_home.php';
|
||||
}
|
||||
}
|
||||
|
||||
if($p == 'register'){
|
||||
$page = '_register.php';
|
||||
}
|
||||
if($p == 'newEntry'){
|
||||
$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">
|
||||
<br><span> Session User: <?php echo $_SESSION['user']; ?> </span>
|
||||
</div>
|
||||
|
||||
<!-- Zum testen der Daten die ueber die Modals reinkommen -->
|
||||
|
||||
|
||||
|
||||
<!-- Include the footer-->
|
||||
<?php include('segments/_footer.html'); ?>
|
||||
|
||||
|
5
php/logout.php
Normal file
5
php/logout.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header('Location: ../index.php');
|
||||
?>
|
@ -50,7 +50,7 @@ function consumeTan($tanID) {
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<form id="entry-form" action="index.php" method="post">
|
||||
<form id="entry-form" action="index.php?page=newEntry" method="post">
|
||||
<!-- Vorname-->
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
|
@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
<div>
|
||||
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
|
||||
<div class="carousel-inner" style="height: 100px;">
|
||||
@ -36,7 +38,11 @@
|
||||
<form class="form-inline my-2 my-lg-0">
|
||||
<div class="btn-group" role="group" aria-label="Basic example">
|
||||
<!-- 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>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -4,27 +4,27 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` (
|
||||
`tanID` INT NOT NULL ,
|
||||
`vorname` LONGTEXT NOT NULL ,
|
||||
`nachname` LONGTEXT NOT NULL ,
|
||||
`geburtstag` LONGTEXT NOT NULL ,
|
||||
`wohnort` LONGTEXT NOT NULL ,
|
||||
`strasse` LONGTEXT NOT NULL ,
|
||||
`geburtstag` LONGTEXT DEFAULT NULL ,
|
||||
`wohnort` LONGTEXT DEFAULT NULL ,
|
||||
`strasse` LONGTEXT DEFAULT NULL ,
|
||||
`kennenUns` LONGTEXT NOT NULL ,
|
||||
`festnetz` LONGTEXT NOT NULL ,
|
||||
`handynummer` LONGTEXT NOT NULL ,
|
||||
`festnetz` LONGTEXT DEFAULT NULL ,
|
||||
`handynummer` LONGTEXT DEFAULT NULL ,
|
||||
`email` LONGTEXT NOT NULL ,
|
||||
`hobbies` LONGTEXT NOT NULL ,
|
||||
`berufswunsch` LONGTEXT NOT NULL ,
|
||||
`essen` LONGTEXT NOT NULL ,
|
||||
`insel` LONGTEXT NOT NULL ,
|
||||
`film` LONGTEXT NOT NULL ,
|
||||
`sport` LONGTEXT NOT NULL ,
|
||||
`charakter` LONGTEXT NOT NULL ,
|
||||
`tier` LONGTEXT NOT NULL ,
|
||||
`musik` LONGTEXT NOT NULL ,
|
||||
`game` LONGTEXT NOT NULL ,
|
||||
`alk` LONGTEXT NOT NULL ,
|
||||
`story` LONGTEXT NOT NULL ,
|
||||
`absturz` LONGTEXT NOT NULL ,
|
||||
`trinkspiel` LONGTEXT NOT NULL ,
|
||||
`hobbies` LONGTEXT DEFAULT NULL ,
|
||||
`berufswunsch` LONGTEXT DEFAULT NULL ,
|
||||
`essen` LONGTEXT DEFAULT NULL ,
|
||||
`insel` LONGTEXT DEFAULT NULL ,
|
||||
`film` LONGTEXT DEFAULT NULL ,
|
||||
`sport` LONGTEXT DEFAULT NULL ,
|
||||
`charakter` LONGTEXT DEFAULT NULL ,
|
||||
`tier` LONGTEXT DEFAULT NULL ,
|
||||
`musik` LONGTEXT DEFAULT NULL ,
|
||||
`game` LONGTEXT DEFAULT NULL ,
|
||||
`alk` LONGTEXT DEFAULT NULL ,
|
||||
`story` LONGTEXT DEFAULT NULL ,
|
||||
`absturz` LONGTEXT DEFAULT NULL ,
|
||||
`trinkspiel` LONGTEXT DEFAULT NULL ,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`tanID`)) ENGINE = InnoDB;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user