hjkhhrterwefdgdfgdfgdfgdgdfgdfgdsvstertrt
bnmbertsdfsdfgdfgdfgfffdgdfgdfgrtdfg
/
home
/
u254050281
/
domains
/
indiannadarcouncil.in
/
public_html
/
apanel
/
Upload FileeE
HOME
<?php // Database configuration $db = mysqli_connect("localhost","u254050281_Wl8K9","Indianadar@2024","u254050281_iTofe"); // Create a MySQLi instance $mysqli = new mysqli($host, $username, $password, $dbname); // Check connection if ($mysqli->connect_error) { die("Connection failed: " . $mysqli->connect_error); } // Initialize variables to hold messages $success_message = ''; $error_message = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['title']) && isset($_POST['content']) && !empty($_POST['title']) && !empty($_POST['content'])) { $title = trim($_POST['title']); $content = trim($_POST['content']); // Prepare the SQL statement $stmt = $mysqli->prepare("INSERT INTO announcements (title, content) VALUES (?, ?)"); $stmt->bind_param('ss', $title, $content); // Execute the statement if ($stmt->execute()) { // Set success message $success_message = "Announcement added successfully!"; // Close the statement $stmt->close(); // Redirect to the index page (or any other page) header("Location: dashboard.php"); // Adjust this to your target page exit(); } else { $error_message = "Error: " . $stmt->error; } } else { $error_message = "Both title and content are required."; } } // Close the connection $mysqli->close(); ?>