-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatepost.php
65 lines (59 loc) · 2.25 KB
/
createpost.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
<?php
session_start();
include("config.php");
//include("upload.php");
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if (!$connection) {
echo "kle vaata oma server üle, armas inimene, eks";
}
if (!$_SESSION['username']) {
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Create a new post onto this magnificent site \\ Reddit</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://bootswatch.com/3/simplex/bootstrap.min.css"/>
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<link rel="stylesheet" href="stylesheet.css"/>
</head>
<?php
include("header.php");
?>
<body class="centered-wrapper">
<div class="centered-content">
<form method="post">
<legend>Hello create new post thanks</legend>
<label><b>The title of your new postitus</b></label><br>
<input type="text" style="width: 500px" name="title"/><br>
<label><b>The content of your new postitus</b></label><br>
<input type="text" style="width: 500px; height: 250px" name="content"/><br><br>
<!--<input type="file" name="fileToUpload"/>-->
<input type="submit">
<?php
if (isset($_REQUEST['title']) and isset($_REQUEST['content'])) {
$title = escape($connection, $_REQUEST['title']);
$content = escape($connection, $_REQUEST['content']);
$name = $_SESSION['username'];
$ok = "ok";
//$target = "uploads/";
//$target = $target . basename($_FILES['fileToUpload']);
//$picture = $_FILES['fileToUpload'];
//$sql = "INSERT INTO 164347_posts (content, time, username, title, picture) VALUES ('$content', NOW(),
//'$name', '$title', '$picture')";
$sql = "INSERT INTO 164347_posts (content, time, username, title, picture) VALUES ('$content', NOW(),
'$name', '$title', '$ok')";
if ($connection->query($sql) === true) {
$message = "Success!";
echo "<script type='text/javascript'>alert('$message');</script>";
header("Location: index.php");
}
}
?>
</form>
</div>
</body>
</html>