-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_post.php
91 lines (78 loc) · 3.53 KB
/
send_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
<?php include('php/server.php'); ?>
<?php include('php/sendpost.php'); ?>
<?php
$title = "Devuger - Create Post";
if (isset($_GET['logout'])) {
session_destroy();
unset($_SESSION['username']);
header("location: index.php");
}
?>
<?php include('includes/header.php'); ?>
<?php if (!isset($_SESSION['username'])) : ?>
<main class="content-wrapper">
<div class="container">
<div class="row align-items-start">
<div class="col-md-12 text-center">
<br><br><br><br>
<h1>Oh boy :/ login first!</h1>
<p><a class="green" href="login.php">click here to login buddy :)</a></p>
</div>
</div>
</div>
</main>
<?php elseif (isset($_SESSION['username'])) : ?>
<main class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-9">
<br><br>
<form method="post" action="send_post.php">
<div>
<label><b>Title:</b></label>
<input class="form-control" type="text" name="post_title" required>
</div>
<br>
<div>
<label><b>Content:</b></label>
<textarea class="form-control rounded-0" id="exampleFormControlTextarea1" rows="10" name="post_content"></textarea>
</div>
<br>
<div>
<label><b>Post to:</b></label>
<input id="sub-to" class="form-control" type="text" name="post_to" required>
<?php
$u = $_SESSION['username'];
$b = "SELECT * FROM users WHERE username = '$u'";
$r = mysqli_query($db, $b);
$row = mysqli_fetch_assoc($r);
$id = $row['id'];
$query = "SELECT DISTINCT(sname) FROM subforum WHERE id IN(SELECT subId FROM subscriptions WHERE userId = '$id') ORDER BY sname LIMIT 20";
$q = mysqli_query($db, $query);
$subs = array();
$pos = 0;
if (mysqli_num_rows($q) > 0) {
while ($row = mysqli_fetch_assoc($q)) {
foreach ($row as $i => $value) {
$subs[$pos] = $row['sname'];
$pos++;
}
}
echo '<p>';
for ($i = 0; $i < count($subs); $i++) {
echo '<span class="subs-span green" id="' . $subs[$i] . '" onclick="clicado(this.id);">' . $subs[$i] . '</span> ';
}
echo '<p>';
}
?>
</div>
<br>
<button class="btn btn-primary btn-green mb-2" type="submit" name="post_send">Send Post</button>
</form>
</div>
<?php include('includes/right_side_bar.php'); ?>
</div>
</div>
</main>
<?php endif ?>
<?php include('includes/footer.php'); ?>