-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposts.php
33 lines (27 loc) · 923 Bytes
/
posts.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
<?php
$servername = "localhost:3306";
$serverusername = "admin";
$serverpassword = "LL0921jj";
$dbname = "barterBetterDb";
$username = $_POST['username'];
$title = $_POST['title'];
$subtitle = $_POST['subtitle'];
$body = $_POST['body'];
$images = $_POST['images'];
$region = $_POST['region'];
$category = $_POST['category'];
$conn = new mysqli($servername, $serverusername, $serverpassword, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO `posts`(`id`, `title`, `subtitle`, `body`, `images`, `region`, `category`, `timestamp`) VALUES ('NULL','$title','$subtitle','$body','$images','$region','$category',current_timestamp())";
if ($conn->query($sql) === TRUE) {
echo "Your post was successfully submitted!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
header("Location: ./timeline.html");
exit();
?>