Create a seperate page for adding demands
In addition I've added a new field for quality.
This commit is contained in:
parent
a1bde1f459
commit
4871de62d3
|
@ -0,0 +1,62 @@
|
||||||
|
<?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>Board</h1>
|
||||||
|
<!--The Title ends here -->
|
||||||
|
|
||||||
|
<!-- The sidebar naviagtion begins here -->
|
||||||
|
<nav>
|
||||||
|
<?php
|
||||||
|
include 'navigation.php';
|
||||||
|
?>
|
||||||
|
</nav>
|
||||||
|
<!-- The sidebar naviagtion ends here -->
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- The Post function begins here -->
|
||||||
|
<div>
|
||||||
|
<h2>New entry</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo "<form class= 'post-box p' method='POST' action='".pbinsert($con)."'>
|
||||||
|
Title<br>
|
||||||
|
<input type='text' name='title' required><br>
|
||||||
|
Quality<br>
|
||||||
|
<select name='quality'>
|
||||||
|
<option selected='selected' value='1'>New</option>
|
||||||
|
<option value='2'>Used</option>
|
||||||
|
</select><br>
|
||||||
|
<br>
|
||||||
|
Maximum<br>
|
||||||
|
<input type='number' name='piecesMax' value='' ><br>
|
||||||
|
<br>
|
||||||
|
Minimum<br>
|
||||||
|
<input type='number' name='piecesMin' value='' required><br>
|
||||||
|
<br>
|
||||||
|
Description<br>
|
||||||
|
<textarea rows='6' cols='40' name='text' required></textarea><br>
|
||||||
|
<button type='submit' name='submit'>SUBMIT</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
16
board.php
16
board.php
|
@ -32,24 +32,10 @@ date_default_timezone_set('Europe/Amsterdam');
|
||||||
</div>
|
</div>
|
||||||
<!-- The Post function begins here -->
|
<!-- The Post function begins here -->
|
||||||
<div>
|
<div>
|
||||||
|
<h2>Open Requests</h2>
|
||||||
<h2>Neuer Eintrag</h2>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo
|
|
||||||
"<form class= 'post-box p' method='POST' action='".pbinsert($con)."'> <br /> Maximum<br/>
|
|
||||||
<input type='hidden' name='userId' value=''>
|
|
||||||
<input type='number' name='piecesMax' value='' > <br /> Minimum<br/>
|
|
||||||
<input type='number' name='piecesMin' value='' > <br />
|
|
||||||
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
|
|
||||||
<br /> Produktbeschreibung<br/>
|
|
||||||
<textarea rows='6' cols='40' name='text'></textarea><br />
|
|
||||||
<button type='submit' name='submit'>SUBMIT</button>
|
|
||||||
</form>";
|
|
||||||
pbget($con);
|
pbget($con);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -76,16 +76,19 @@ function pbinsert ($con)
|
||||||
$userId = get_userid($con);
|
$userId = get_userid($con);
|
||||||
$piecesMax = $_POST['piecesMax'];
|
$piecesMax = $_POST['piecesMax'];
|
||||||
$piecesMin = $_POST['piecesMin'];
|
$piecesMin = $_POST['piecesMin'];
|
||||||
$date = $_POST['date'];
|
$qualityId = $_POST['quality'];
|
||||||
|
$title = $_POST['title'];
|
||||||
$text = $_POST['text'];
|
$text = $_POST['text'];
|
||||||
// Inserts Data into Database
|
// Inserts Data into Database
|
||||||
$sql = "INSERT INTO demands ( piecesMax, piecesMin, text, date, userId)
|
$sql = "INSERT INTO demands (piecesMax, piecesMin, demandText,
|
||||||
VALUES ('$piecesMax', '$piecesMin', '$text', '$date', '$userId')";
|
demandTitle, userId, qualityId)
|
||||||
|
VALUES ('$piecesMax', '$piecesMin', '$text', '$title',
|
||||||
|
'$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 webside
|
// A function to insert the own posts from the database into the website
|
||||||
function pbget($con)
|
function pbget($con)
|
||||||
{
|
{
|
||||||
global $con;
|
global $con;
|
||||||
|
@ -94,7 +97,7 @@ function pbget($con)
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
echo "<div class='post-box'><p>";
|
echo "<div class='post-box'><p>";
|
||||||
echo $row['date'] . "<br>";
|
echo $row['date'] . "<br>";
|
||||||
echo $row['text'] ."<br>" , "<br /> Maximum<br/>";
|
echo $row['demandText'] ."<br>" , "<br /> Maximum<br/>";
|
||||||
echo $row['piecesMax'] ."<br /> Minimum<br/>";
|
echo $row['piecesMax'] ."<br /> Minimum<br/>";
|
||||||
echo $row['piecesMin'];
|
echo $row['piecesMin'];
|
||||||
echo "</p>
|
echo "</p>
|
||||||
|
@ -109,7 +112,7 @@ function pbget($con)
|
||||||
<input type='hidden' name='piecesMax' value='".$row['piecesMax']."'>
|
<input type='hidden' name='piecesMax' value='".$row['piecesMax']."'>
|
||||||
<input type='hidden' name='piecesMin' value='".$row['piecesMin']."'>
|
<input type='hidden' name='piecesMin' value='".$row['piecesMin']."'>
|
||||||
<input type='hidden' name='date' value='".$row['date']."'>
|
<input type='hidden' name='date' value='".$row['date']."'>
|
||||||
<input type='hidden' name='text' value='".$row['text']."'>
|
<input type='hidden' name='text' value='".$row['demandText']."'>
|
||||||
<button>Edit</button>
|
<button>Edit</button>
|
||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
|
@ -131,7 +134,7 @@ function editpost($con)
|
||||||
$sql = "UPDATE demands
|
$sql = "UPDATE demands
|
||||||
SET piecesMax='$piecesMax',
|
SET piecesMax='$piecesMax',
|
||||||
piecesMin='$piecesMin',
|
piecesMin='$piecesMin',
|
||||||
text='$text'
|
demandText='$text'
|
||||||
WHERE demandId='$demandId'";
|
WHERE demandId='$demandId'";
|
||||||
$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");
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
echo '<ul>
|
echo '<ul>
|
||||||
<li><a href="index.php">Logout</a></li>
|
<li><a href="index.php">Logout</a></li>
|
||||||
<li><a href="board.php">Board</a></li>
|
<li><a href="board.php">Board</a></li>
|
||||||
|
<li><a href="add_request.php">New Request</a></li>
|
||||||
<li><a class="active" href="home.php">Home</a></li>
|
<li><a class="active" href="home.php">Home</a></li>
|
||||||
</ul>'
|
</ul>'
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -10,3 +10,7 @@ insert into users (userLogin, userPass, userEmail)
|
||||||
values ('demander','password','demander@example.com'),
|
values ('demander','password','demander@example.com'),
|
||||||
('provider','password','provider@example.com'),
|
('provider','password','provider@example.com'),
|
||||||
('admin','password','admin@example.com');
|
('admin','password','admin@example.com');
|
||||||
|
|
||||||
|
insert into quality (qualityName)
|
||||||
|
values ('new'),
|
||||||
|
('used');
|
||||||
|
|
|
@ -31,16 +31,25 @@ CREATE TABLE if not exists `tags` (
|
||||||
`text` varchar(50) NOT NULL
|
`text` varchar(50) NOT NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE if not exists `quality` (
|
||||||
|
`qualityId` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
`qualityName` varchar(20) NOT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE if not exists `demands` (
|
CREATE TABLE if not exists `demands` (
|
||||||
`demandId` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
`demandId` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
`text` text,
|
`demandTitle` varchar(50) NOT NULL,
|
||||||
|
`demandText` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
|
||||||
`piecesMin` int(11) NOT NULL,
|
`piecesMin` int(11) NOT NULL,
|
||||||
`piecesMax` int(11) DEFAULT NULL,
|
`piecesMax` int(11) DEFAULT NULL,
|
||||||
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
`qualityId` int(11) NOT NULL,
|
||||||
`userId` int(11) NOT NULL,
|
`userId` int(11) NOT NULL,
|
||||||
`tagId` int(11) NULL,
|
`tagId` int(11) NULL,
|
||||||
CONSTRAINT `fk_demands_userId`
|
CONSTRAINT `fk_demands_userId`
|
||||||
FOREIGN KEY (userId) REFERENCES users (userId),
|
FOREIGN KEY (userId) REFERENCES users (userId),
|
||||||
|
CONSTRAINT `fk_demands_qualityId`
|
||||||
|
FOREIGN KEY (qualityId) REFERENCES quality (qualityId),
|
||||||
CONSTRAINT `fk_tagId`
|
CONSTRAINT `fk_tagId`
|
||||||
FOREIGN KEY (tagId) REFERENCES tags (tagId)
|
FOREIGN KEY (tagId) REFERENCES tags (tagId)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
Loading…
Reference in New Issue