-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_post.php
254 lines (189 loc) · 7.15 KB
/
edit_post.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
include_once('resources/init.php');
$post = get_posts($_GET['id']);
if(isset($_POST['title'],$_POST['contents'],$_POST['category'])){
$errors = array();
$title = trim($_POST['title']);
$contents = trim($_POST['contents']);
if(empty($title)){
$errors[] = 'You need to supply a title';
}
else if(strlen($title)>255){
$errors[] = 'The title can not be longer than 255 characters';
}
if(empty($contents)){
$errors[] = 'You need to supply some text';
}
if(!category_exists('id',$_POST['category'])){
$errors[] = 'That category does not exists';
}
if(empty($errors)){
edit_post($_GET['id'],$title,$contents,$_POST['category']);
header("Location:index.php?id={$post[0]['post_id']}");
die();
}
}
?>
<!DOCTYPE html>
<!--[if lt IE 8 ]><html class="no-js ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
<!--[if IE 9 ]><html class="no-js ie ie9" lang="en"> <![endif]-->
<!--[if (gte IE 8)|!(IE)]><!--><html class="no-js" lang="en"> <!--<![endif]-->
<head>
<!--- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>WEBMED</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- mobile specific metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- CSS
================================================== -->
<link rel="stylesheet" href="css/default.css">
<link rel="stylesheet" href="css/layout.css">
<link rel="stylesheet" href="css/media-queries.css">
<!-- Script
================================================== -->
<script src="js/modernizr.js"></script>
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="images/favicon.png" />
</head>
<body>
<!-- Header
================================================== -->
<header id="top">
<div class="row">
<div class="header-content twelve columns" >
<h1 id="logo-text"><a href="index.php" title="">WEBMED</a></h1>
<p id="intro" >Your Health is our first priority!</p>
</div>
</div>
<nav id="nav-wrap" style="z-index:9999;">
<a class="mobile-btn" href="#nav-wrap" title="Show navigation">Show Menu</a>
<a class="mobile-btn" href="#" title="Hide navigation">Hide Menu</a>
<div class="row">
<ul id="nav" class="nav">
<li><a href="index.php">Home</a>
</li>
<li><a class="fixed-navbar" href="medi.php">Medicines</a></li>
<li>
<a class="fixed-navbar" href="doctor.php">Primary Doctors</a>
<ul>
<li><a href="CardioDoctor.php">Cardiologists</a></li>
<li><a href="DermaDoctor.php">Dermatologists</a></li>
<li><a href="EndoDoctor.php">Endocrinologists</a>
<li><a href="GastroDoctor.php">Gastroenterologists</a></li>
<li><a href="GyneDoctor.php">Gynecologists</a></li>
<li><a href="MediDoctor.php">Medicine doctors</a></li>
<li><a href="NeuroDoctor.php">Neurologists</a></li>
<li><a href="Pedidoctor.php">Peditricians</a></li>
</ul>
</li>
<li><a class="fixed-navbar" href="blog.php">Blog</a></li>
<!-- <li><a class="fixed-navbar" href="#">Surgical specialists</a>
<ul>
<li><a href="#">Cardiothoracic surgery</a></li>
<li><a href="#">General surgery</a></li>
<li><a href="#">Neuro surgery</a></li>
<li><a href="#">Paediatric surgery</a></li>
<li><a href="#">plastic surgery</a></li>
<li><a href="#">Urological surgery</a></li>
</ul>
</li> -->
<!-- <li><a class="fixed-navbar" href="#">Others</a>
<ul>
<li><a href="#">Blog</a></li>
<li><a href="#">Research</a></li>
<li><a href="#">Weekly health advice</a></li>
</ul>
</li> -->
<li><a class="fixed-navbar" href="#contact">Contact</a></li>
</ul> <!-- end #nav -->
</div>
</nav> <!-- end #nav-wrap -->
</header> <!-- Header End -->
<!-- Content
================================================== -->
<div id="content-wrap">
<div class="row">
<div id="main" class="eight columns">
<article class="entry">
<header class="entry-header">
<?php
if(isset($errors) && !empty($errors)){
echo"<ul><li>",implode("</li><li>",$errors),"</li></ul>";
}
?>
<h2 class="entry-title">
<h2>Add Category</h2>
</h2>
<div class="entry-meta">
<form action='' method='post'>
<div>
<label for='title'>Title</label>
<input type='text' name='title' value='<?php echo $post[0]['title']; ?>' />
</div>
<div>
<label for='contents'>Content</label>
<textarea name='contents' cols=20 rows=10><?php echo $post[0]['contents']; ?></textarea>
</div>
<div>
<label for='category'>Category</label>
<select name='category'>
<?php
foreach(get_categories() as $category){
$selected = ($category['name'] == $post[0]['name']) ? 'selected' : '';
?>
<option value='<?php echo $category['id'] ?>' <?php echo $selected; ?> ><?php echo $category['name'] ?></option>
<?php
}
?>
</select>
</div>
<p><input type='submit' value='Add Post' /></p>
</form>
</div>
</header>
<div class="entry-content">
<p><!--insert here--></p>
</div>
</article> <!-- end entry -->
</div> <!-- end main -->
<div id="sidebar" class="four columns">
<div class="widget widget_categories group">
<h3>Categories</h3>
<?php
foreach(get_categories() as $category){
?>
<p><a href="manage_category.php?id=<?php echo $category['id'];?>"><?php echo $category['name']; ?></a>
<?php
}
?>
</div>
<div class="widget widget_text group">
<h3>Daily Quote of the Day</h3>
<p>What is success?</p><br/>
<p>"Success is not final; failure is not fatal: It is the courage to continue that counts." - Winston S. Churchill</p>
</div>
</div> <!-- end sidebar -->
</div> <!-- end row -->
</div> <!-- end content-wrap -->
<!-- Footer
================================================== -->
<footer>
<div class="row">
<p class="copyright">Copyright © 2021, webMed</p>
</div> <!-- End row -->
<div id="go-top"><a class="smoothscroll" title="Back to Top" href="#top"><i class="fa fa-chevron-up"></i></a></div>
</footer> <!-- End Footer-->
<!-- Java Script
================================================== -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.10.2.min.js"><\/script>')</script>
<script type="text/javascript" src="js/jquery-migrate-1.2.1.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>