Editing: header.php
Kembali
<?php // Connect to MySQL database $conn = mysqli_connect("localhost", "root", "", "blog_db"); // Retrieve form data $title = $_POST['title']; $content = $_POST['content']; // Insert the new post into the database $query = "INSERT INTO blog_posts (title, content) VALUES ('$title', '$content')"; mysqli_query($conn, $query); // Confirm that the post was added echo "Your post has been added!"; ?> <!DOCTYPE html> <html> <head> <form action="add.php" method="post"> <label for="title">Title:</label><br> <input type="text" id="title" name="title" required><br> <label for="content">Content:</label><br> <textarea id="content" name="content" required></textarea><br> <input type="submit" value="Submit Post"> </form> </body> </html>
SIMPAN PERUBAHAN