From 0790b1d8e71986094aca2e982d29aa527562f125 Mon Sep 17 00:00:00 2001 From: Jannik Date: Thu, 20 Aug 2020 13:02:53 +0300 Subject: [PATCH] Code in Funktionen umgelagert p1 --- functions.php | 6 +- insertEntry.php | 239 +++++++-------------------------------------- modal.php | 255 +++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 256 insertions(+), 244 deletions(-) diff --git a/functions.php b/functions.php index 7da0a73..2c22970 100644 --- a/functions.php +++ b/functions.php @@ -3,7 +3,7 @@ require 'settings.php'; class Funcs { - public static function InsertDatas($conn, $ds, $de, $n,$tisch) + public static function InsertDatas($conn, $ds, $de, $n,$tisch,$tnum) { $day = $_SESSION["day"]; $month = $_SESSION["month"]; @@ -21,14 +21,14 @@ class Funcs VALUES ('$year', '$month', '$daystart', '1', '$name', '$table')"; $conn->query($sql); } - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='1'"; + $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='$table'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while ($row = $result->fetch_assoc()) { //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch1"] = array($row['uniqueid'], $row['month'], $row['day'], $row['reserviert'], $row['reserviertvon'], $row['tisch'], $row['year']); + $_SESSION[$tnum] = array($row['uniqueid'], $row['month'], $row['day'], $row['reserviert'], $row['reserviertvon'], $row['tisch'], $row['year']); //echo $_SESSION["Tisch3"][6]; } $_SESSION["sucessmessage"] = '
diff --git a/insertEntry.php b/insertEntry.php index c3ff405..c7c6c9e 100644 --- a/insertEntry.php +++ b/insertEntry.php @@ -8,227 +8,58 @@ if(isset($_POST['reservierenBtnTisch1'])){ $daystart=$_POST['daystart']; $dayend = $_POST['dayend']; $name = $_POST['reservierterName']; - funcs::InsertDatas($conn, $daystart, $dayend, $name,1); + funcs::InsertDatas($conn, $daystart, $dayend, $name,1,"Tisch1"); } else if(isset($_POST['reservierenBtnTisch2'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; - $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 2; + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; + $name = $_POST['reservierterName']; + funcs::InsertDatas($conn, $daystart, $dayend, $name,2,"Tisch2"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; - -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Tisch erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='2'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch2"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { - echo "Error: " . $sql . "
" . $conn->error; -} - -} +} else if(isset($_POST['reservierenBtnTisch3'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; - $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 3; + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; + $name = $_POST['reservierterName']; + funcs::InsertDatas($conn, $daystart, $dayend, $name,3,"Tisch3"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; - -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Tisch erfolgreich reserviert.
'; - - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='3'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch3"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { - echo "Error: " . $sql . "
" . $conn->error; -} - -} +} else if(isset($_POST['reservierenBtnTisch4'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; - $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 4; + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; + $name = $_POST['reservierterName']; + funcs::InsertDatas($conn, $daystart, $dayend, $name,4,"Tisch4"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; - -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Tisch erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='4'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch4"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { - echo "Error: " . $sql . "
" . $conn->error; -} - -} +} else if(isset($_POST['reservierenBtnTisch5'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; - $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 5; + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; + $name = $_POST['reservierterName']; + funcs::InsertDatas($conn, $daystart, $dayend, $name,5,"Tisch5"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; - -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Tisch erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='5'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch5"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { - echo "Error: " . $sql . "
" . $conn->error; -} - -} +} else if(isset($_POST['reservierenBtnTisch6'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 6; + funcs::InsertDatas($conn, $daystart, $dayend, $name,6,"Tisch6"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; +} -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Tisch erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='6'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Tisch6"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { -echo "Error: " . $sql . "
" . $conn->error; -} - -} - -else if(isset($_POST['reservierenBtnpark1'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; +else if(isset($_POST['reservierenBtnPark1'])){ + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 7; + funcs::InsertDatas($conn, $daystart, $dayend, $name,7,"Park1"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; +} -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Parkplatz 1 erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='7'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Park1"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { -echo "Error: " . $sql . "
" . $conn->error; -} - -} - -else if(isset($_POST['reservierenBtnpark2'])){ - $month = $_SESSION["month"]; - $day = $_SESSION["day"]; +else if(isset($_POST['reservierenBtnPark2'])){ + $daystart=$_POST['daystart']; + $dayend = $_POST['dayend']; $name = $_POST['reservierterName']; - $year = $_SESSION["year"]; - $table = 8; + funcs::InsertDatas($conn, $daystart, $dayend, $name,8,"Park2"); - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) -VALUES ('$year', '$month', '$day', '1', '$name', '$table')"; - -if ($conn->query($sql) === TRUE) { - $_SESSION["sucessmessage"] = '
- Du hast den Parkplatz 2 erfolgreich reserviert.
'; - $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='4'"; - $result = $conn->query($sql); - - if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - //echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."
" ; - $_SESSION["Park2"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']); - //echo $_SESSION["Tisch3"][6]; - } - } - header("location:index.php?result=gotrecords"); - -} else { -echo "Error: " . $sql . "
" . $conn->error; -} - -} +} diff --git a/modal.php b/modal.php index 5b16bc5..ad84e3c 100644 --- a/modal.php +++ b/modal.php @@ -30,7 +30,6 @@ if (session_status() == PHP_SESSION_NONE) { ?>
-
- - - +
- +
@@ -109,12 +101,39 @@ if (session_status() == PHP_SESSION_NONE) {
- - - - - - - - - - - - - -