Fixed error messages

This commit is contained in:
Furentes
2019-05-23 09:12:05 +02:00
parent 61d77ff1a1
commit e381050e1d
5 changed files with 43 additions and 13 deletions

View File

@ -8,6 +8,7 @@ section.main {
max-width: 960px; max-width: 960px;
margin: 0 auto; margin: 0 auto;
padding: 80px 0 0; padding: 80px 0 0;
margin-bottom: 100px;
} }
/*# sourceMappingURL=main.css.map */ /*# sourceMappingURL=main.css.map */

View File

@ -1 +1 @@
{"version":3,"sourceRoot":"","sources":["../scss/main.scss"],"names":[],"mappings":"AAAA;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA","file":"main.css"} {"version":3,"sourceRoot":"","sources":["../scss/main.scss"],"names":[],"mappings":"AAAA;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA","file":"main.css"}

View File

@ -101,17 +101,6 @@ require_once(__DIR__."/inc/head.php");
} }
?> ?>
<?php <?php
foreach ($errors as $key=>$value):
?>
<span style="color: red;">
<?= $value ?>
</span><br>
<?php
endforeach;
if($success == true) {
echo '<span style="color: green;">Post bearbeitet!</span><br>';
}
if ($action == 'view'): if ($action == 'view'):
?> ?>
<div> <div>
@ -131,6 +120,15 @@ require_once(__DIR__."/inc/head.php");
?> ?>
</div> </div>
<?php <?php
foreach ($errors as $key=>$value):
?>
<br><span style="color: red;">
<?= $value ?>
</span>
<?php
endforeach;
?>
<?php
if ($auth->isLoggedIn()) { if ($auth->isLoggedIn()) {
?> ?>
<p> <p>
@ -162,6 +160,15 @@ require_once(__DIR__."/inc/head.php");
if ($action == 'new'): if ($action == 'new'):
?> ?>
<h2>Neuer Beitrag</h2> <h2>Neuer Beitrag</h2>
<?php
foreach ($errors as $key=>$value):
?>
<span style="color: red;">
<?= $value ?>
</span><br>
<?php
endforeach;
?>
<form action="<?= htmlspecialchars($_SERVER['REQUEST_URI']) ?>" method="post" class="clearfix"> <form action="<?= htmlspecialchars($_SERVER['REQUEST_URI']) ?>" method="post" class="clearfix">
<label for="title">Titel</label> <label for="title">Titel</label>
<input type="text" name="title" id="title" value="<?= (isset($_POST['title'])) ? htmlspecialchars($_POST['title']) : ''; ?>"><br> <input type="text" name="title" id="title" value="<?= (isset($_POST['title'])) ? htmlspecialchars($_POST['title']) : ''; ?>"><br>
@ -175,6 +182,18 @@ require_once(__DIR__."/inc/head.php");
if ($action == 'edit'): if ($action == 'edit'):
?> ?>
<h2>Beitrag Bearbeiten</h2> <h2>Beitrag Bearbeiten</h2>
<?php
if($success == true) {
echo '<span style="color: green;">Post bearbeitet!</span><br>';
}
foreach ($errors as $key=>$value):
?>
<span style="color: red;">
<?= $value ?>
</span><br>
<?php
endforeach;
?>
<form action="<?= htmlspecialchars($_SERVER['REQUEST_URI']) ?>" method="post" class="clearfix"> <form action="<?= htmlspecialchars($_SERVER['REQUEST_URI']) ?>" method="post" class="clearfix">
<label for="title">Titel</label> <label for="title">Titel</label>
<input type="text" name="title" id="title" value="<?= (isset($data['title'])) ? $data['title'] : $ptitle; ?>"><br> <input type="text" name="title" id="title" value="<?= (isset($data['title'])) ? $data['title'] : $ptitle; ?>"><br>

View File

@ -8,4 +8,5 @@ section.main {
max-width: 960px; max-width: 960px;
margin: 0 auto; margin: 0 auto;
padding: 80px 0 0; padding: 80px 0 0;
margin-bottom: 100px;
} }

View File

@ -10,7 +10,7 @@ $errors = [];
$action = ''; $action = '';
$data = []; $data = [];
$view = false; $view = false;
$success = false;
if(isset($_GET['view'])) { if(isset($_GET['view'])) {
if (!empty($_GET['view']) && \is_numeric($_GET['view'])) { if (!empty($_GET['view']) && \is_numeric($_GET['view'])) {
@ -19,6 +19,12 @@ if(isset($_GET['view'])) {
if(isset($_POST['update'])) { if(isset($_POST['update'])) {
$update = $auth->updateUserRole($view, $_POST['role']); $update = $auth->updateUserRole($view, $_POST['role']);
if(is_array($update)) {
$errors = $update;
} else {
$success = true;
}
} }
if(isset($_POST['delete'])) { if(isset($_POST['delete'])) {
@ -46,6 +52,9 @@ require_once(__DIR__."/inc/head.php");
<?= ($view) ? '<a href="/users.php">Zurück</a>' : '<a href="/">Zurück</a>' ?> <?= ($view) ? '<a href="/users.php">Zurück</a>' : '<a href="/">Zurück</a>' ?>
<h2>Benutzer</h2> <h2>Benutzer</h2>
<?php <?php
if($success == true) {
echo '<span style="color: green;">Benutzer bearbeitet!</span><br>';
}
foreach ($errors as $key=>$value): foreach ($errors as $key=>$value):
?> ?>
<span style="color: red;"> <span style="color: red;">