Hi
yu ```
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$post_title = $_POST["post-title"];
$post_content = $_POST["post-content"];
$post_image = $_FILES["post-image"];
$post_video = $_FILES["post-video"];
$target_dir = "uploads/";
$target_file_image = $target_dir . basename($post_image["name"]);
$target_file_video = $target_dir . basename($post_video["name"]);
move_uploaded_file($post_image["tmp_name"], $target_file_image);
move_uploaded_file($post_video["tmp_name"], $target_file_video);
$sql = "INSERT INTO posts (title, content, image, video) VALUES ('$post_title', '$post_content', '$target_file_image', '$target_file_video')";
if ($conn->query($sql) === TRUE) {
echo "Post submitted successfully!";
} else {
echo "Error: " . $sql . "
" . $conn->error; } } ?> query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "
";
echo "";
}
} else {
echo "No posts found!";
}
$conn->close();
?>
```
" . $conn->error; } } ?> query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "
" . $row["title"] . "
"; echo "" . $row["content"] . "
"; echo "
Comments
Post a Comment