Revert "switched tan from unique id to index"
This reverts commit 268a8ea290
.
This commit is contained in:
parent
6e8ff050fd
commit
8ad92f6a0b
@ -44,6 +44,11 @@
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
<?php include('segments/_entryForm.php'); ?>
|
||||
>>>>>>> parent of 268a8ea... switched tan from unique id to index
|
||||
|
||||
<!-- Include the footer-->
|
||||
<?php include('segments/_footer.html'); ?>
|
||||
|
@ -1,7 +1,13 @@
|
||||
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() {
|
||||
@ -18,7 +24,12 @@ 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', {
|
||||
|
230
segments/_entryForm.php
Normal file
230
segments/_entryForm.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?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'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!-- Container fuer entry form-->
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12">
|
||||
<form id="entry-form" action="" method="post">
|
||||
<!-- Vorname-->
|
||||
<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>
|
||||
<!-- Nachname-->
|
||||
<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>
|
||||
<!-- Geburtstag-->
|
||||
<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>
|
||||
<!-- Wohnort-->
|
||||
<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>
|
||||
<!-- Strasse-->
|
||||
<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>
|
||||
<!-- Woher kennen-->
|
||||
<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>
|
||||
<!-- Festnetz-->
|
||||
<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>
|
||||
<!-- Handynummer-->
|
||||
<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>
|
||||
<!-- E-Mail-->
|
||||
<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>
|
||||
<!-- Hobbies-->
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Hobbies</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="entryHobbies" aria-label="Small" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
<!-- Berufswunsch-->
|
||||
<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>
|
||||
<!-- Essen-->
|
||||
<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>
|
||||
<!-- Insel-->
|
||||
<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>
|
||||
<!-- Film-->
|
||||
<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>
|
||||
<!-- Sport-->
|
||||
<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>
|
||||
<!-- Charaker-->
|
||||
<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>
|
||||
<!-- Tier -->
|
||||
<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>
|
||||
<!-- Musik -->
|
||||
<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>
|
||||
<!-- Game -->
|
||||
<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>
|
||||
<!-- Alk-->
|
||||
<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>
|
||||
<!-- Story-->
|
||||
<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>
|
||||
<!-- Absturz -->
|
||||
<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>
|
||||
<!-- Trinkspiel -->
|
||||
<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>
|
||||
<!-- TAN -->
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<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">
|
||||
</div>
|
||||
<!-- Absenden Button-->
|
||||
<div class="modal-footer">
|
||||
<button id="btnAbsenden" type="submit" class="btn btn-primary">Absenden</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- Ende container entry form -->
|
33
sql/entiresTable.sql
Normal file
33
sql/entiresTable.sql
Normal file
@ -0,0 +1,33 @@
|
||||
CREATE TABLE `kd42696_ipr-projekt`.`entries` (
|
||||
`entryID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`userID` INT NOT NULL ,
|
||||
`tanID` INT NOT NULL ,
|
||||
`vorname` LONGTEXT NOT NULL ,
|
||||
`nachname` LONGTEXT NOT NULL ,
|
||||
`geburtstag` LONGTEXT NOT NULL ,
|
||||
`wohnort` LONGTEXT NOT NULL ,
|
||||
`strasse` LONGTEXT NOT NULL ,
|
||||
`kennenUns` LONGTEXT NOT NULL ,
|
||||
`festnetz` LONGTEXT NOT NULL ,
|
||||
`handynummer` LONGTEXT NOT 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 ,
|
||||
PRIMARY KEY (`entryID`),
|
||||
UNIQUE (`userID`),
|
||||
UNIQUE (`tanID`)) ENGINE = InnoDB;
|
||||
|
||||
ALTER TABLE `entries` ADD FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE `entries` ADD FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
Loading…
Reference in New Issue
Block a user