<?php
session_start();
include 'connection.php';

$user_id = $_SESSION['user_id'];

if (isset($_FILES['shop_image']) && $_FILES['shop_image']['error'] === 0) {
    $imageName = time() . '_' . str_replace(' ', '_', $_FILES['shop_image']['name']);
    $targetPath = "../uploads/" . $imageName;

    if (move_uploaded_file($_FILES['shop_image']['tmp_name'], $targetPath)) {
        mysqli_query($conn, "UPDATE users SET shop_image='$imageName' WHERE id='$user_id'");
    }
}

header("Location: admin.php?page=profile");
exit;