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 @@
-
-
-
-
-