-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
49 lines (42 loc) · 1.8 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include 'includes/head.php';
if (!isset($_GET['id'])) {
header('Location: admin.php');
}
if (isset($_POST['update'])) {
$article->update($_POST);
}
?>
<!-- Header Section -->
<header>
<h1>Update Article</h1>
</header>
<!-- Main Section -->
<main>
<form action="" method="post">
<div class="form-input">
<input type="hidden" name="id" value="<?= $data['id']; ?>">
<label for="article_title">Article Title</label>
<input type="text" name="article_title" id="article_title" placeholder="Article Title" <?php if (Validator::hasValidationError('article_title')): ?> style="border-color: red;" <?php endif; ?> value="<?= $_SESSION['old_data']['article_title'] ?? $data['article_title']; ?>">
<p class="error">
<?= Validator::getValidationError("article_title"); ?>
</p>
</div>
<div class="form-input">
<label for="publishing_date">Publishing Date</label>
<input type="date" name="publishing_date" id="publishing_date" placeholder="Publishing Date" <?php if (Validator::hasValidationError('publishing_date')): ?> style="border-color: red;" <?php endif; ?> value="<?= $_SESSION['old_data']['publishing_date'] ?? $data['publishing_date']; ?>">
<p class="error">
<?= Validator::getValidationError("publishing_date"); ?>
</p>
</div>
<div class="form-input">
<label for="content">Content</label>
<textarea name="content" id="content" rows="10" <?php if (Validator::hasValidationError('content')): ?> style="border-color: red;" <?php endif; ?>><?= $_SESSION['old_data']['content'] ?? $data['content']; ?></textarea>
<p class="error">
<?= Validator::getValidationError("content"); ?>
</p>
</div>
<button type="submit" name="update">Update</button>
</form>
</main>
<?php include 'includes/foot.php' ?>