From b4f3db4208c761c4c0a44fe90d35ec85b5015a7a Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Mon, 20 Feb 2017 22:05:30 +0100 Subject: [PATCH] check if the maximumPieces is bigger than the minimumPieces --- add_demand.php | 2 +- css/stylesheet.css | 3 +++ functions.php | 38 +++++++++++++++++++----------- show_demand.php | 58 ---------------------------------------------- 4 files changed, 29 insertions(+), 72 deletions(-) delete mode 100644 show_demand.php diff --git a/add_demand.php b/add_demand.php index 7c07602..bf7613f 100644 --- a/add_demand.php +++ b/add_demand.php @@ -46,7 +46,7 @@ date_default_timezone_set('Europe/Amsterdam');

Maximum
-
+

Minimum

diff --git a/css/stylesheet.css b/css/stylesheet.css index 2bbdcf5..7016cb0 100644 --- a/css/stylesheet.css +++ b/css/stylesheet.css @@ -94,3 +94,6 @@ li { .delete-form button:hover{ opacity: 1; } +*.warning { + color:red; +} diff --git a/functions.php b/functions.php index 1eda332..511bcf6 100644 --- a/functions.php +++ b/functions.php @@ -80,11 +80,17 @@ function post_demand ($con) $title = $_POST['title']; $text = $_POST['text']; // Inserts Data into Database - $sql = "INSERT INTO demands (piecesMax, piecesMin, demandText, - demandTitle, userId, qualityId) - VALUES ('$piecesMax', '$piecesMin', '$text', '$title', - '$userId', '$qualityId')"; - $result = mysqli_query($con, $sql) or die(mysqli_error($con)); + if ($piecesMax <= $piecesMin) { + echo " + The Maximum must be bigger than the Minimum! + "; + } else { + $sql = "INSERT INTO demands (piecesMax, piecesMin, demandText, + demandTitle, userId, qualityId) + VALUES ('$piecesMax', '$piecesMin', '$text', '$title', + '$userId', '$qualityId')"; + $result = mysqli_query($con, $sql) or die(mysqli_error($con)); + } } } @@ -131,14 +137,20 @@ function edit_demand ($con) $text = $_POST['text']; // Inserts Updates Database - $sql = "UPDATE demands - SET piecesMax='$piecesMax', - piecesMin='$piecesMin', - demandTitle='$title', - demandText='$text' - WHERE demandId='$demandId'"; - $result = mysqli_query($con, $sql) or die(mysqli_error($con)); - header("Location: board.php"); + if ($piecesMax <= $piecesMin) { + echo " + The Maximum must be bigger than the Minimum! + "; + } else { + $sql = "UPDATE demands + SET piecesMax='$piecesMax', + piecesMin='$piecesMin', + demandTitle='$title', + demandText='$text' + WHERE demandId='$demandId'"; + $result = mysqli_query($con, $sql) or die(mysqli_error($con)); + header("Location: board.php"); + } } } // A function to delete a post diff --git a/show_demand.php b/show_demand.php deleted file mode 100644 index 18e4965..0000000 --- a/show_demand.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - -
-
-
- -

Edit

- - - - - -
-
- -

Edit Board

- - -
- -
Maximum
-
Minimum
- -
Produktbeschreibung
-
- - "; - ?> -
- -