-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmit-post.php
27 lines (21 loc) · 963 Bytes
/
submit-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
<?php
include_once 'connect.php';
if(isset($_POST['submit'])){
$username = $_POST['user_name'];
$description = $_POST['discription'];
$target = "photos/".basename($_FILES['fileToUpload']['name']);
$image = $_FILES['fileToUpload']['name'];
$query = "INSERT INTO POSTS(username, photo, description)
VALUES ('$username', 'photos/$image', '$description') ";
if(mysqli_query($conn, $query)){
move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target);
$increment_posts = mysqli_query($conn, "UPDATE users
SET posts = posts+1
WHERE username = '$username'"
);
$conn->close();
header("Location: feed.php?username=$username");
exit();
}
}
?>