-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.php
47 lines (32 loc) · 1.23 KB
/
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
<?php require_once 'includes/global.inc.php'; ?>
<?php
//profile.php
//check to see if they're logged in
if (!isset($_SESSION['logged_in'])) {
header("Location: login.php");
}
$id = $_GET["id"];
$postsController = new PostsController();
$post = $postsController->get($id);
$usersController = new UsersController();
$userData = $usersController->getUserForPostId($id);
$page_title = $post->title;
//check to see that the form has been submitted
if (isset($_POST['submit-post'])) {
//retrieve the $_POST variables
$postContent = $_POST['post-content'];
$post->content = $postContent;
$post->save();
$message = "Changes Saved<br/>";
}
require_once('./includes/header.php');
?>
<div>Created at : <?php echo $post->created_at; ?></div>
<div>Author : <?php echo $userData->username; ?></div>
<?php echo $message; ?>
<form action=<?php echo 'post.php?id=' . $post->id; ?> method="post">
<textarea name="post-content" type="text" cols="80" rows="20" value="<?php echo $post->content; ?>"><?php echo $post->content; ?></textarea>
<div><input type="submit" value="Update" name="submit-post" /></div>
</form>
<?php /* require_once('./markitup/markitup_template.php'); */ ?>
<?php require_once('./includes/footer.php'); ?>