parent
8ad92f6a0b
commit
dc524ac00c
41
index.php
41
index.php
@ -8,50 +8,27 @@
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<!-- Include the header-->
|
||||
<?php include('segments/_header.html'); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="content">
|
||||
|
||||
<button id="btnCreateTan" type="button" class="btn btn-info">Erstelle Tan</button>
|
||||
</div>
|
||||
|
||||
<div id="phpTest">
|
||||
LoginModalData:
|
||||
Welcome <?php echo $_POST["loginName"]; ?><br>
|
||||
Your Password is: <?php echo $_POST["loginPassword"]; ?><br>
|
||||
<br>
|
||||
RegisterModalData:
|
||||
Welcome <?php echo $_POST["registerName"]; ?><br>
|
||||
Your Password is: <?php echo $_POST["registerPassword"]; ?><br>
|
||||
Your Mail Adress is: <?php echo $_POST["registerMail"]; ?><br>
|
||||
</div>
|
||||
|
||||
<?php include('segments/_entry.html'); ?>
|
||||
|
||||
<?php echo $_POST["entryVorname"]; ?><br>
|
||||
<?php echo $_POST["entryNachname"]; ?><br>
|
||||
<?php echo $_POST["entryMail"]; ?><br>
|
||||
<?php echo $_POST["entryKennen"]; ?><br>
|
||||
<?php echo $_POST["entryGame"]; ?><br>
|
||||
<?php echo $_POST["entryTrinkspiel"]; ?><br>
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
<!-- Zum testen der Daten die ueber die Modals reinkommen -->
|
||||
<!-- <?php include('segments/_indexTestLoginVals.php'); ?> -->
|
||||
|
||||
<!-- Include the entryForm-->
|
||||
<?php include('segments/_entryForm.php'); ?>
|
||||
>>>>>>> parent of 268a8ea... switched tan from unique id to index
|
||||
|
||||
<!-- Include the footer-->
|
||||
<?php include('segments/_footer.html'); ?>
|
||||
|
||||
<!-- Optional JavaScript -->
|
||||
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
|
@ -1,13 +1,7 @@
|
||||
window.addEventListener('load', async () => {
|
||||
console.log("Seite geladen");
|
||||
<<<<<<< HEAD
|
||||
getNewUniqueLink();
|
||||
document.getElementById('create').addEventListener('click' , async (event) => createEntry());
|
||||
=======
|
||||
//getNewUniqueLink();
|
||||
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
|
||||
document.getElementById('btnAbsenden').addEventListener('click' , async (event) => createEntry());
|
||||
>>>>>>> parent of 268a8ea... switched tan from unique id to index
|
||||
})
|
||||
|
||||
async function getNewUniqueLink() {
|
||||
@ -22,23 +16,3 @@ async function getNewUniqueLink() {
|
||||
}
|
||||
|
||||
}
|
||||
async function createEntry() {
|
||||
event.preventDefault()
|
||||
<<<<<<< HEAD
|
||||
const formData = new formData(document.getElementById('create-form'));
|
||||
=======
|
||||
console.log("Absenden gedrueckt!!!!");
|
||||
const formData = new formData(document.getElementById('entry-form'));
|
||||
>>>>>>> parent of 268a8ea... switched tan from unique id to index
|
||||
|
||||
try {
|
||||
const response = await fetch('php/login.php', {
|
||||
method: 'post',
|
||||
body: formData
|
||||
});
|
||||
const jsonData = await response.json();
|
||||
|
||||
} catch (e) {
|
||||
console.log("Fehler");
|
||||
}
|
||||
}
|
||||
|
@ -8,22 +8,39 @@
|
||||
|
||||
insertTan($uniqueID);
|
||||
|
||||
$resultStr = getTanID($uniqueID);
|
||||
|
||||
$HTMLJSON = array('html' => $resultStr);
|
||||
echo json_encode($HTMLJSON);
|
||||
|
||||
function insertTan($tan) {
|
||||
require('../dbConnect.php'); //Erstellt variable mit dem namen $database
|
||||
|
||||
$stmt = $database->prepare("INSERT INTO tans (tan, used) VALUES (?, ?)");
|
||||
$stmt = $database->prepare("INSERT INTO tans (tan, userID, used) VALUES (?, ?, ?)");
|
||||
|
||||
$false = false;
|
||||
$stmt->bind_param("si", $tan, $false);
|
||||
$used = false;
|
||||
$userid = 1;
|
||||
$stmt->bind_param("ssi", $tan, $userid, $used);
|
||||
|
||||
try {
|
||||
$stmt->execute();
|
||||
$database->close();
|
||||
} catch (PDOException $e) {
|
||||
$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function getTanID($tan){
|
||||
require('../dbConnect.php'); //Erstellt variable mit dem namen $database
|
||||
$abfrage = "SELECT `id` FROM `tans` WHERE `tan` = '" . $tan . "'";
|
||||
|
||||
$ergebnis = mysqli_query($database, $abfrage);
|
||||
|
||||
$row = $ergebnis->fetch_object();
|
||||
$resultStr = $row->id;
|
||||
|
||||
|
||||
return $resultStr;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,6 +1,3 @@
|
||||
Link to Project:
|
||||
|
||||
https://icaotix.github.io/ipr-projekt/
|
||||
|
||||
Info: index.php
|
||||
form with php_post in line 61 and 97, feel free to change the destination path.
|
||||
|
@ -1,194 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col" >
|
||||
</div>
|
||||
|
||||
<div class="col-10">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
<h3>Write a new friendsbook entry!</h3>
|
||||
</div>
|
||||
<form id="entry-form" action="index.php" method="post">
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Vorname*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryVorname" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Nachname*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryNachname" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Geburtstag</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryGeburtstag" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Wohnort</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryOrt" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Straße</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryStraße" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Woher kennen wir uns?*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryKennen" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Festnetz</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryFestnetz" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Handynummer</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryHandy" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">E-Mail*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryMail" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Hobbys</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryHobbys" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Berufswunsch</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryBeruf" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Das könnte ich jeden Tag essen</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryEssen" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Was ich auf eine Insel mitnehmen würde</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryInsel" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Lieblingsfilm</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryFilm" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Lieblingssport</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entrySport" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Coolster Film oder Spielecharaker</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryCharakter" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Mein Lieblingstier</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryTier" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Lieblingsmusik(Genre, Interpret, Titel)</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryMusik" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Geilstes Game</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryGame" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Lieblings alkoholisches Getränk</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryAlk" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Meine heftigste Suffstory</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryStory" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Letzer Absturz</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryAbsturz" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Lieblings Trinkspiel</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryTrinkspiel" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">friendsTAN*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryTAN" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="entry" type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
if(isset($_POST['tan'])){
|
||||
if(isset($_POST['tanID'])){
|
||||
//echo "Tan ->" . $_POST['tan'] . "<-";
|
||||
if($_POST['tan'] != ""){
|
||||
if($_POST['tanID'] != ""){
|
||||
addEntry();
|
||||
consumeTan($_POST['tan']);
|
||||
consumeTan($_POST['tanID']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,11 +12,11 @@
|
||||
|
||||
}
|
||||
|
||||
function consumeTan($tan) {
|
||||
require('../dbConnect.php'); //Erstellt variable mit dem namen $database
|
||||
function consumeTan($tanID) {
|
||||
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 . "'";
|
||||
$abfrage = "SELECT `used`, `tan` FROM `tans` WHERE `id` = '" . $tanID . "'";
|
||||
$ergebnis = mysqli_query($database, $abfrage);
|
||||
|
||||
if($ergebnis->num_rows == 0){
|
||||
@ -26,21 +26,16 @@ function consumeTan($tan) {
|
||||
|
||||
$resultStr = "";
|
||||
|
||||
while ($row = $ergebnis->fetch_assoc()) {
|
||||
$resultStr = $resultStr . $row["used"] . ' ' . $row["tan"] . '<br>';
|
||||
if($row["used"] == 1){
|
||||
echo "Tan schon verbraucht";
|
||||
return;
|
||||
}
|
||||
|
||||
$row = $ergebnis->fetch_object();
|
||||
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'] . "'");
|
||||
$update = $database->query("UPDATE `tans` SET `used`= true WHERE `id` = '" . $_POST['tanID'] . "'");
|
||||
|
||||
echo "Tan verbraucht " . $_POST['tan'];
|
||||
echo "Tan verbraucht " . $_POST['tanID'];
|
||||
}
|
||||
|
||||
?>
|
||||
@ -50,7 +45,7 @@ function consumeTan($tan) {
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12">
|
||||
<form id="entry-form" action="" method="post">
|
||||
<form id="entry-form" action="index.php" method="post">
|
||||
<!-- Vorname-->
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
@ -217,14 +212,14 @@ function consumeTan($tan) {
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Eintrags-TAN*</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryTan" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
<input type="text" class="form-control" name="tanID" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
<!-- Absenden Button-->
|
||||
<div class="modal-footer">
|
||||
<button id="btnAbsenden" type="submit" class="btn btn-primary">Absenden</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</fo+rm>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Ende container entry form -->
|
||||
|
@ -1,4 +1,3 @@
|
||||
<!--Carousel-->
|
||||
<div>
|
||||
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
|
||||
<div class="carousel-inner" style="height: 100px;">
|
||||
|
10
segments/_indexTestLoginVals.php
Normal file
10
segments/_indexTestLoginVals.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div id="phpTest">
|
||||
LoginModalData:
|
||||
Welcome <?php echo $_POST["loginName"]; ?><br>
|
||||
Your Password is: <?php echo $_POST["loginPassword"]; ?><br>
|
||||
<br>
|
||||
RegisterModalData:
|
||||
Welcome <?php echo $_POST["registerName"]; ?><br>
|
||||
Your Password is: <?php echo $_POST["registerPassword"]; ?><br>
|
||||
Your Mail Adress is: <?php echo $_POST["registerMail"]; ?><br>
|
||||
</div>
|
@ -1,5 +1,5 @@
|
||||
CREATE TABLE `kd42696_ipr-projekt`.`entries` (
|
||||
`entryID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`id` INT NOT NULL AUTO_INCREMENT ,
|
||||
`userID` INT NOT NULL ,
|
||||
`tanID` INT NOT NULL ,
|
||||
`vorname` LONGTEXT NOT NULL ,
|
||||
@ -25,7 +25,7 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` (
|
||||
`story` LONGTEXT NOT NULL ,
|
||||
`absturz` LONGTEXT NOT NULL ,
|
||||
`trinkspiel` LONGTEXT NOT NULL ,
|
||||
PRIMARY KEY (`entryID`),
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`userID`),
|
||||
UNIQUE (`tanID`)) ENGINE = InnoDB;
|
||||
|
||||
|
@ -3,6 +3,6 @@ CREATE TABLE `user` (
|
||||
`user` VARCHAR(50) NOT NULL DEFAULT '0',
|
||||
`email` VARCHAR(100) NOT NULL DEFAULT '0',
|
||||
`password` VARCHAR(100) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`ID`)
|
||||
PRIMARY KEY (`ID`),
|
||||
UNIQUE INDEX `user` (`user`)
|
||||
)
|
||||
);
|
Loading…
Reference in New Issue
Block a user