-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.txt
More file actions
92 lines (59 loc) · 3.22 KB
/
Copy pathnotes.txt
File metadata and controls
92 lines (59 loc) · 3.22 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
INSERT INTO `threads` (`thread_id`, `thread_title`, `thread_desc`, `thread_img`, `thread_cat_id`, `thread_user_id`, `timestamp`, `thread_likes`, `thread_dislike`) VALUES ('1', 'this is thread title', 'this is thread description', '45645yht54ws5t', '1', '1', current_timestamp(), '', '');
$sql = "INSERT INTO `images` (`description`, `imagename`) VALUES ('$name', '$newImageName')";
$sql = "INSERT INTO `threads` (`thread_title`, `thread_desc`, `thread_img`, `thread_cat_id`, `thread_user_id`, `timestamp`, `thread_likes`, `thread_dislike`) VALUES ('$thread_title', '$thread_desc', '$newImageName', '$thread_cat_id', '1', current_timestamp(), '0', '0')";
$isInserted = false;
if(isset($_POST["submit"])){
require 'partials/_dbconnect.php';
$name = $_POST["image-name"];
if(isset($_FILES["image"]) && $_FILES["image"]["error"] === 0){
$fileName = $_FILES["image"]["name"];
$fileSize = $_FILES["image"]["size"];
$tmpName = $_FILES["image"]["tmp_name"];
$validImageExtensions = ['jpg', 'jpeg', 'png'];
$imageExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if(!in_array($imageExtension, $validImageExtensions)){
echo "<script>alert('Invalid Image Extension');</script>";
}
else if($fileSize > 10000000){
echo "<script>alert('Image size is too large');</script>";
}
else{
$newImageName = uniqid().'.'.$imageExtension;
move_uploaded_file($tmpName, 'img/'.$newImageName);
$thread_title = $_POST["post-title"];
$thread_desc = $_POST["post-description"];
$thread_cat = $_POST["selected-cat"];
$sql = "SELECT category_id FROM `categories` WHERE category_name=$thread_cat";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)){
$thread_cat_id = $row['category_id'];
}
$sql = "INSERT INTO `threads` (`thread_title`, `thread_desc`, `thread_img`, `thread_cat_id`, `thread_user_id`, `timestamp`) VALUES ('$thread_title', '$thread_desc', '$newImageName', '$thread_cat_id', '1', current_timestamp())";
$result = mysqli_query($conn, $sql);
if($result){
$isInserted = true;
}
}
}
else {
echo "<script>alert('Image not exist');</script>";
}
}
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Culpa vel nulla molestias earum harum, commodi iusto repellendus qui maxime doloremque dolore, voluptatum natus minus repudiandae sit in, amet voluptates quia vero neque modi reiciendis exercitationem architecto itaque? Unde illo error suscipit nisi fuga eum, a expedita impedit minus aliquam ratione.
add comments and display comments
like and dislike
login / signup / logout
about page
recent page
trending page
thread page
user profile page
search functionality
new logo
c id
c content
thread_id
comment by
c time
INSERT INTO `comments` (`comment_id`, `comment_content`, `thread_id`, `comment_by`, `comment_time`) VALUES ('1', 'this is a comment', '1', '1', current_timestamp());
vnrZ8BpwdyNHkIA