check if the maximumPieces is bigger than the minimumPieces
This commit is contained in:
parent
27ee918b63
commit
b4f3db4208
|
@ -46,7 +46,7 @@ date_default_timezone_set('Europe/Amsterdam');
|
||||||
</select><br>
|
</select><br>
|
||||||
<br>
|
<br>
|
||||||
Maximum<br>
|
Maximum<br>
|
||||||
<input type='number' name='piecesMax' value='' ><br>
|
<input type='number' name='piecesMax' value='' required><br>
|
||||||
<br>
|
<br>
|
||||||
Minimum<br>
|
Minimum<br>
|
||||||
<input type='number' name='piecesMin' value='' required><br>
|
<input type='number' name='piecesMin' value='' required><br>
|
||||||
|
|
|
@ -94,3 +94,6 @@ li {
|
||||||
.delete-form button:hover{
|
.delete-form button:hover{
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
*.warning {
|
||||||
|
color:red;
|
||||||
|
}
|
||||||
|
|
|
@ -80,12 +80,18 @@ function post_demand ($con)
|
||||||
$title = $_POST['title'];
|
$title = $_POST['title'];
|
||||||
$text = $_POST['text'];
|
$text = $_POST['text'];
|
||||||
// Inserts Data into Database
|
// Inserts Data into Database
|
||||||
|
if ($piecesMax <= $piecesMin) {
|
||||||
|
echo "<strong class='warning'>
|
||||||
|
The Maximum must be bigger than the Minimum!
|
||||||
|
</strong>";
|
||||||
|
} else {
|
||||||
$sql = "INSERT INTO demands (piecesMax, piecesMin, demandText,
|
$sql = "INSERT INTO demands (piecesMax, piecesMin, demandText,
|
||||||
demandTitle, userId, qualityId)
|
demandTitle, userId, qualityId)
|
||||||
VALUES ('$piecesMax', '$piecesMin', '$text', '$title',
|
VALUES ('$piecesMax', '$piecesMin', '$text', '$title',
|
||||||
'$userId', '$qualityId')";
|
'$userId', '$qualityId')";
|
||||||
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
|
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A function to insert the own posts from the database into the website
|
// A function to insert the own posts from the database into the website
|
||||||
|
@ -131,6 +137,11 @@ function edit_demand ($con)
|
||||||
$text = $_POST['text'];
|
$text = $_POST['text'];
|
||||||
|
|
||||||
// Inserts Updates Database
|
// Inserts Updates Database
|
||||||
|
if ($piecesMax <= $piecesMin) {
|
||||||
|
echo "<strong class='warning'>
|
||||||
|
The Maximum must be bigger than the Minimum!
|
||||||
|
</strong>";
|
||||||
|
} else {
|
||||||
$sql = "UPDATE demands
|
$sql = "UPDATE demands
|
||||||
SET piecesMax='$piecesMax',
|
SET piecesMax='$piecesMax',
|
||||||
piecesMin='$piecesMin',
|
piecesMin='$piecesMin',
|
||||||
|
@ -140,6 +151,7 @@ function edit_demand ($con)
|
||||||
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
|
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
|
||||||
header("Location: board.php");
|
header("Location: board.php");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// A function to delete a post
|
// A function to delete a post
|
||||||
function delete_demand($con)
|
function delete_demand($con)
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?php
|
|
||||||
include 'functions.php';
|
|
||||||
date_default_timezone_set('Europe/Amsterdam');
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<!-- enable utf-8 encoding for umlauts etc.-->
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<!-- Description of what this dose -->
|
|
||||||
<meta name ="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<!-- link to the default css file -->
|
|
||||||
<link rel="stylesheet" href="css/stylesheet.css"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<header>
|
|
||||||
<!-- The title begins here -->
|
|
||||||
<h1>Edit</h1>
|
|
||||||
<!-- The title ends here -->
|
|
||||||
|
|
||||||
<!-- The sidebar naviagtion begins here -->
|
|
||||||
<nav>
|
|
||||||
<?php
|
|
||||||
include 'navigation.php';
|
|
||||||
?>
|
|
||||||
</nav>
|
|
||||||
<!-- The sidebar naviagtion ends here -->
|
|
||||||
</header>
|
|
||||||
</div>
|
|
||||||
<!-- Edit function begins here -->
|
|
||||||
<h2>Edit Board</h2>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$userId = $_POST['userId'];
|
|
||||||
$demandId = $_POST['demandId'];
|
|
||||||
$piecesMax = $_POST['piecesMax'];
|
|
||||||
$piecesMin = $_POST['piecesMin'];
|
|
||||||
$title= $_POST['title'];
|
|
||||||
$text = $_POST['text'];
|
|
||||||
|
|
||||||
echo
|
|
||||||
"<form method='POST' action='".edit_post($con)."'>
|
|
||||||
<input type='text' name='title' value='".$title."'><br>
|
|
||||||
<input type='hidden' name='userId' value='".$userId."'>
|
|
||||||
<input type='hidden' name='demandId' value='".$demandId."'><br /> Maximum<br/>
|
|
||||||
<input type='number' name='piecesMax' value='".$piecesMax."'> <br /> Minimum<br/>
|
|
||||||
<input type='number' name='piecesMin' value='".$piecesMin."'>
|
|
||||||
<br /> Produktbeschreibung<br/>
|
|
||||||
<textarea name='text'>".$text."</textarea><br />
|
|
||||||
<button type='submit' name='edit'>Edit</button>
|
|
||||||
</form>";
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue