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

if (!isset($_SESSION['user_id'])) exit("Unauthorized.");

$user_id = $_SESSION['user_id'];

$firstname = trim($_POST['firstname']);
$lastname  = trim($_POST['lastname']);
$phone     = trim($_POST['phone']);

$stmt = $pdo->prepare("UPDATE users SET firstname=?, lastname=?, phone=? WHERE id=?");
$stmt->execute([$firstname, $lastname, $phone, $user_id]);

header("Location: ../users/profile_edit?success=Profile updated successfully");
exit;
