forked from JarekSed/Manny-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewPost.php
More file actions
39 lines (37 loc) · 1.17 KB
/
Copy pathviewPost.php
File metadata and controls
39 lines (37 loc) · 1.17 KB
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
<?php
require_once("common.php");
$authorID = getID();
if(!$authorID){
echo "not logged in";
?>
<a href = "index.php">Back to home</a>
<?php
}
?>
<h3>Manny's BlogPost</h3>
<a href = "index.php">Back to Home Page</a></br>
<?php
if(!isset($_POST['postTitle'])|| !isset($_POST['postTitle'])){
echo "<strong>invalid post. input into both fields</strong></br>";
echo '<a href = "post.php">Make another post</a></br>';
}else{
$postTitle = $_POST['postTitle'];
$postBody = $_POST['postBody'];
unset($_POST['postTitle']);
unset($_POST['postBOdy']);
$command = "INSERT INTO Posts (title, content, author_id) VALUES(:title, :content, :author_id)";
$stmt = $db->prepare($command);
$stmt->bindParam(':title', $postTitle);
$stmt->bindParam(':content', $postBody);
$stmt->bindParam('author_id', $authorID);
if(!$stmt->execute()){
echo "screwed up mysql command";
}else{
echo "Post Made! </br>";
getPosts();
?>
<a href = "post.php">Make another post</a></br>
<?php
}
}
?>