-
Notifications
You must be signed in to change notification settings - Fork 39
/
new.php
50 lines (40 loc) · 1.6 KB
/
new.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
<?php
require_once 'connect.php';
require_once 'header.php';
require_once 'security.php';
if (isset($_POST['submit'])) {
$title = mysqli_real_escape_string($dbcon, $_POST['title']);
$description = mysqli_real_escape_string($dbcon, $_POST ['description']);
$slug = slug($title);
$date = date('Y-m-d H:i');
$posted_by = mysqli_real_escape_string($dbcon, $_SESSION['username']);
$sql = "INSERT INTO posts (title, description, slug,posted_by, date) VALUES('$title', '$description', '$slug', '$posted_by', '$date')";
mysqli_query($dbcon, $sql) or die("failed to post" . mysqli_connect_error());
$permalink = "p/".mysqli_insert_id($dbcon) ."/".$slug;
printf("Posted successfully. <meta http-equiv='refresh' content='2; url=%s'/>",
$permalink);
} else {
?>
<div class="w3-container">
<div class="w3-card-4">
<div class="w3-container w3-teal">
<h2>New Post</h2>
</div>
<form class="w3-container" method="POST">
<p>
<label>Title</label>
<input type="text" class="w3-input w3-border" name="title" required>
</p>
<p>
<label>Description</label>
<textarea id = "description" row="30" cols="50" class="w3-input w3-border" name="description" required/></textarea>
</p>
<p>
<input type="submit" class="w3-btn w3-teal w3-round" name="submit" value="Post">
</p>
</form>
</div>
</div>
<?php
}
include("footer.php");