rename various files and functions to add consistency

This commit is contained in:
Andreas Zweili 2017-02-20 21:34:28 +01:00
parent bcd41be9a8
commit 5efaae8bb3
6 changed files with 67 additions and 9 deletions

View File

@ -36,7 +36,7 @@ date_default_timezone_set('Europe/Amsterdam');
<h2>New entry</h2>
<?php
echo "<form class= 'post-box p' method='POST' action='".pbinsert($con)."'>
echo "<form class= 'post-box p' method='POST' action='".post_demand($con)."'>
Title<br>
<input type='text' name='title' required><br>
Quality<br>

View File

@ -34,7 +34,7 @@ date_default_timezone_set('Europe/Amsterdam');
<div>
<h2>Open Requests</h2>
<?php
get_post_titles($con);
get_demand_titles($con);
?>
</div>
</body>

58
edit_demand.php Normal file
View File

@ -0,0 +1,58 @@
<?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_demand($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>

View File

@ -69,7 +69,7 @@ function get_userid ($con)
}
// A function to post a demand
function pbinsert ($con)
function post_demand ($con)
{
if (isset($_POST['submit'])) {
global $con;
@ -89,7 +89,7 @@ function pbinsert ($con)
}
// A function to insert the own posts from the database into the website
function get_post_titles($con)
function get_demand_titles ($con)
{
global $con;
$sql = "SELECT * FROM demands";
@ -105,7 +105,7 @@ function get_post_titles($con)
<button type='submit' name= 'deletepost'> Delete</button>
</form>
<form class= 'edit-form' method= 'POST' action='editboard.php'>
<form class= 'edit-form' method= 'POST' action='edit_demand.php'>
<input type='hidden' name='userId' value='".$row['userId']."'>
<input type='hidden' name='demandId' value='".$row['demandId']."'>
<input type='hidden' name='piecesMax' value='".$row['piecesMax']."'>
@ -120,7 +120,7 @@ function get_post_titles($con)
// A function to edit a demand
function edit_post($con)
function edit_demand ($con)
{
if (isset($_POST['edit'])) {
global $con;
@ -142,7 +142,7 @@ function edit_post($con)
}
}
// A function to delete a post
function delete_post($con)
function delete_demand($con)
{
if (isset($_POST['deletepost'])) {
global $con;
@ -154,4 +154,4 @@ function delete_post($con)
header('Location: board.php');
}
}
?>
?>

View File

@ -2,7 +2,7 @@
echo '<ul>
<li><a href="index.php">Logout</a></li>
<li><a href="board.php">Board</a></li>
<li><a href="add_request.php">New Request</a></li>
<li><a href="add_demand.php">New Demand</a></li>
<li><a class="active" href="home.php">Home</a></li>
</ul>'
?>