-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogEdit.php
114 lines (102 loc) · 5.01 KB
/
blogEdit.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
$message='';
session_start();
if($_SESSION['id'] == null) {
header('Location: index.php');
}
require_once '../vendor/autoload.php';
$login = new App\classes\Login();
$blog=new App\classes\Blog();
if(isset($_GET['logout'])) {
$login->adminLogout();
}
$queryResult2 = $blog->getAllPublishedCategoryInfo();
$id = $_GET['id'];
$queryResult=$blog->getBlogInfo($id);
$data=mysqli_fetch_assoc($queryResult);
if(isset($_POST['btn'])){
$blog->updateBlogInfo($_POST);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Dashboard</title>
<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
</head>
<body>
<?php include 'includes/menu.php'; ?>
<div class="container" style="margin-top: 10px;">
<div class="row">
<div class="col-sm-8 mx-auto">
<div class="card">
<h4 class="text-success"><?php echo $message;?></h4>
<div class="card-body">
<form action="" method="POST" name="editBlogForm" enctype="multipart/form-data">
<div class="form-group row">
<label for="inputEmail3" class="col-sm-3 col-form-label">Category Name</label>
<div class="col-sm-9">
<select name="category_id" class="form-control">
<option>---Select Category Name---</option>
<?php while ( $category = mysqli_fetch_assoc($queryResult2)) { ?>
<option value="<?php echo $category['id']; ?>"><?php echo $category['category_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-3 col-form-label">Blog Title</label>
<div class="col-sm-9">
<input type="text" name="blog_title" class="form-control" value="<?php echo $data['blog_title']?>"/>
<input type="hidden" name="blog_id" class="form-control" value="<?php echo $data['id']; ?>"/>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-3 col-form-label">Short Description</label>
<div class="col-sm-9">
<textarea class="form-control" name="short_description"><?php echo $data['short_description']?></textarea>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-3 col-form-label">Long Description</label>
<div class="col-sm-9">
<textarea class="form-control textarea" name="long_description"><?php echo $data['long_description']?></textarea>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-3 col-form-label">Blog Image</label>
<div class="col-sm-9">
<input type="file" name="blog_image" accept="image/*"/>
<img src="<?php echo $data['blog_image']; ?>" alt="" height="50" width="50"/>
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-3 col-form-label">Publication Status</label>
<div class="col-sm-9">
<input type="radio" name="status" value="1" <?php if ($data['status'] == '1') echo "checked";?>> Published
<input type="radio" name="status" value="0" <?php if ($data['status'] == '0') echo "checked";?>> Unpublished
</div>
</div>
<div class="form-group row">
<div class="col-sm-3"></div>
<div class="col-sm-9">
<button type="submit" name="btn" class="btn btn-success btn-block">Update Blog Info</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/js/jquery-3.2.1.js"></script>
<script src="../assets/js/bootstrap.bundle.js"></script>
<script src="../assets/tinymce/js/tinymce/tinymce.min.js"></script>
<script>tinymce.init({ selector:'.textarea' });</script>
<script src="../assets/js/bootstrap.min.js"></script>
<script>
document.forms['editBlogForm'].elements['category_id'].value='<?php echo $data['category_id']; ?>';
</script>
</body>
</html>