-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwritepost.php
80 lines (71 loc) · 2.08 KB
/
writepost.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
<?php require_once "incl/header.php"; ?>
<div class="col-xs-8">
<?php if (isLoggedIn()):
$categories = sqlQuery("SELECT * FROM categories");
$currentCat = 0;
$title = "";
$link = "";
$content = "";
if (isset($_SESSION['posted'])) {
$title = $_SESSION['posted']['title'];
$link = $_SESSION['posted']['link'];
$content =$_SESSION['posted']['content'];
unset($_SESSION['posted']);
}
?>
<h1>Skriv inlägg</h1>
<form action="posts/postsend.php" method="POST">
<div class="formgroup">
<label for="category">Kategori:<br></label>
<select name="category" class="form-control">
<option value="0"> </option>
<?php
foreach ($categories as $category) {
$selected = false;
if (isset($_GET['cat'])) {
if (in_array($_GET['cat'], $category)) {
$currentCat = $category;
$selected = true;
}
}
if ($category['id'] !== "1") {
print "<option value='{$category['id']}'";
if ($selected)
print " selected ";
print ">{$category['fullName']}</option>";
}
}
?>
</select>
</div>
<div class="formgroup">
<label for="title">Titel:</label>
<input type="text" class="form-control" name="title" value='<?php print $title; ?>'>
</div>
<div class="formgroup">
<label for="link">Länk: (glöm inte http://)</label>
<input type="text" class="form-control" name="link" value='<?php print $link; ?>'>
</div>
<div class="formgroup">
<label for="content">Beskrivning:</label>
<textarea name="content" cols="30" rows="10" class="form-control"><?php print $content; ?></textarea>
</div>
<div class="checkbox">
<label><input type="checkbox" name="nsfw"><abbr title="Not Safe For Work">NSFW</abbr></label>
</div>
<input type="submit" class="btn btn-default" value="Skicka">
</form>
<?php else: ?>
<p>Du måste vara inloggad för att skriva inlägg.<br>
<a href='index.php?p=login'>Logga in</a>
</p>
<?php
endif;
if (isset($_SESSION['feedback'])) {
foreach ($_SESSION['feedback'] as $feedback) {
print $feedback . "<br>";
}
unset($_SESSION['feedback']);
}
?>
</div>