<?php
session_start();
include(__DIR__ . '/../includes/db.php');

$user_id = $_SESSION['user_id'];

$file = $_FILES['profile_image'];
$ext  = pathinfo($file['name'], PATHINFO_EXTENSION);
$new  = uniqid() . '.' . $ext;

move_uploaded_file($file['tmp_name'], "../uploads/profile/$new");

$stmt = $conn->prepare("UPDATE users SET profile_image=? WHERE id=?");
$stmt->bind_param("si", $new, $user_id);
$stmt->execute();

header("Location: dashboard.php");
