<?php
session_start();
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: index.php');
    exit;
}
require 'dbconn.php';

$desc = $_POST['desc'] ?? '';
$id = $_POST['id'] ?? '';

if (!empty($desc)) {
    if ($id) {
        // Update logic
        $stmt = $mysqli->prepare("UPDATE about_us SET `description` = ? WHERE id = ?");
        $stmt->bind_param("si", $desc, $id);
        $stmt->execute();
    } else {
        // Insert logic
        $stmt = $mysqli->prepare("INSERT INTO about_us (`description`) VALUES (?)");
        $stmt->bind_param("s", $desc);
        $stmt->execute();
    }

    header("Location: add_aboutus.php?msg=success");
    exit;
} else {
    echo "Description is required.";
}
