| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcfs/ |
Upload File : |
<?php
session_start();
// Check if the user is authenticated
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
header("Location: admin_login.php");
exit();
}
// Database connection
$servername = "localhost";
$username = "nodor"; // Replace with your database username
$password = "D@n33Nao40"; // Replace with your database password
$dbname = "wcfs"; // Replace with your database name
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $conn->real_escape_string($_POST['title']);
$description = $conn->real_escape_string($_POST['description']);
$imagePath = null;
// Handle image upload
if (isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) {
$uploadDir = "uploads/";
$imageName = basename($_FILES['image']['name']);
$imagePath = $uploadDir . $imageName;
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
if (!move_uploaded_file($_FILES['image']['tmp_name'], $imagePath)) {
$imagePath = null;
}
}
// Insert data into the database
$sql = "INSERT INTO updates (title, description, image_path, created_at) VALUES ('$title', '$description', '$imagePath', NOW())";
if ($conn->query($sql) === TRUE) {
// Redirect back to the admin dashboard with a success message
header("Location: admin_dashboard.php?success=1");
exit();
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
$conn->close();
?>