Files
homepage/admin/inhalte/gb/edit.php
2023-12-31 09:35:34 +01:00

45 lines
1.7 KiB
PHP
Raw Permalink Blame History

<h3>Gästebucheintrag ändern</h3>
<?php
if (!isset($_POST['Speichern'])) {
$ts = time();
echo "<img src=\"../img/umgebung/gb/" . $_POST['Titel'] . ".jpg?ts=" . $ts . "\" /><br />";
$sql1 = 'SELECT Autor, Text, Datum FROM gb WHERE ID = "' . $_POST['Titel'] . '"';
$result1 = $db->query($sql1);
$nt1 = $result1->fetch_assoc();
?>
<form action="index.php?section=gb" method="post" enctype="multipart/form-data">
<input type="hidden" name="edit" value="speichern"/>
<input type="hidden" name="id" value="<?php echo $_POST['Titel']; ?>"/>
<label>Autor</label>
<br/>
<input type="text" name="Autor" value="<?php echo $nt1['Autor']; ?>"/>
<br/>
<label>Text</label>
<br/>
<textarea name="Text" cols="90" rows="10"><?php echo $nt1['Text']; ?></textarea>
<br/>
<label>Datum (YYYY-MM-TT)</label>
<br/>
<input type="text" name="Datum" value="<?php echo $nt1['Datum']; ?>"/>
<input type="submit" name="Speichern" value="Speichern"/>
</form>
<?php
} else {
$Autor = $db->real_escape_string($_POST['Autor']);
$Text = $db->real_escape_string($_POST['Text']);
$Datum = $_POST['Datum'];
$sql2 = 'UPDATE gb SET Autor = "' . $Autor . '", Text = "' . $Text . '", Datum = "' . $Datum . '" WHERE ID = "' . $_POST['id'] . '";';
$stmt2 = $db->prepare($sql2);
if (!$stmt2) {
die ('Es konnte kein SQL-Query vorbereitet werden: ' . $db->error);
}
if (!$stmt2->execute()) {
die ('Query konnte nicht ausgef<65>hrt werden: ' . $stmt->error);
}
echo "Der Eintrag wurde geändert<br />";
echo '<a href="index.php?section=gb">Zurück zur Übersicht</a>';
}