<?php
session_name("admin_session");
session_start();
include("connection.php");

if (isset($_POST['update'])) {
    $title = $_POST['title'];
    $username=$_SESSION['username'];

    $logo = $_FILES['logo']['name'];
    $logo_temp = $_FILES['logo']['tmp_name'];
    $logo_destination = 'img/' . $logo;

   

    $number = $_POST['number'];
    $support_email = $_POST['support_email'];
    // $email = $_POST['email'];
    // $answer = $_POST['answer'];

    // Validate and sanitize user input
    $title = mysqli_real_escape_string($conn, $title);
    $number = mysqli_real_escape_string($conn, $number);
    $support_email = mysqli_real_escape_string($conn, $support_email);
    // $email = mysqli_real_escape_string($conn, $email);
    // $answer = mysqli_real_escape_string($conn, $answer);

  
    // Perform the update query using prepared statements
    $updateQuery = "UPDATE user_admin SET title='$title', logo='$logo' , number='$number' ,support_email='$support_email' WHERE username='$username'";
    $res=mysqli_query($conn, $updateQuery);

    if ($res) {
        move_uploaded_file($logo_temp, $logo_destination);

        header("Location: panel_setting.php?success=Updated Successfully!!!");
        exit;
    } else {
        header("Location: panel_setting.php?error=Something went wrong!!!");
        exit;
    }
}
?>
