-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew-post.php
More file actions
53 lines (49 loc) · 1.4 KB
/
new-post.php
File metadata and controls
53 lines (49 loc) · 1.4 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require_once("includes/init.php");
try {
$forum = new forum($_GET['forum']);
} catch (Exception $e) {
header('Location: index.php');
die();
}
if(isset($_POST['title']) && isset($_POST['text']) && $currentUser->isLoggedIn())
{
if($currentUser->newPost($forum->id, $_POST['title'], $_POST['text']))
{
header('Location: forum.php?id='.$forum->id);
die();
}
else
{
$alerts[] = new alert("danger", "Error:", "You post was not sent!");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include("includes/standard_head.php"); ?>
<title>New Post</title>
</head>
<body>
<?php include("includes/navbar.php"); ?>
<div class="container">
<?php displayAlerts(); ?>
<div class="col-md-8 col-md-offset-2">
<h2>You are posting in <a href="/forum?id=<?php echo $forum->id;?>"><span class="red-text"><?php echo $forum->name; ?></span></a></h2>
<br>
<form action="new-post.php<?php echo '?forum='. $forum->id;?>" method="post">
<div class="form-group">
<label>Title:</label>
<input type="text" class="form-control" maxlength="40" name="title" placeholder="Title">
</div>
<div class="form-group">
<label>Text:</label>
<textarea name="text" class="form-control" maxlength="5000" placeholder="Write your post here" required></textarea>
</div>
<button type="submit" class="btn btn-lg btn-primary btn-block">Submit</button>
</form>
</div>
</div>
</body>
</html>