<?php $PAGE_TITLE='Profile'; require __DIR__.'/_layout.php';
$ok=null;$err=null;
if($_SERVER['REQUEST_METHOD']==='POST'){csrf_check();
  $name=trim($_POST['name']??''); $phone=trim($_POST['phone']??''); $newp=$_POST['new_password']??'';
  $pdo->prepare("UPDATE users SET name=?,phone=? WHERE id=?")->execute([$name,$phone,$U['id']]);
  if(strlen($newp)>=6) $pdo->prepare("UPDATE users SET password_hash=? WHERE id=?")->execute([password_hash($newp,PASSWORD_BCRYPT),$U['id']]);
  $ok='আপডেট হয়েছে';
  $s=$pdo->prepare("SELECT * FROM users WHERE id=?"); $s->execute([$U['id']]); $U=$s->fetch();
}
?>
<h2 style="margin-bottom:14px">⚙️ প্রোফাইল</h2>
<div class="card" style="max-width:500px">
<?php if($ok):?><div class="alert ok"><?=e($ok)?></div><?php endif;?>
<form method="post"><?=csrf_field()?>
<div class="field"><label>নাম</label><input class="input" name="name" value="<?=e($U['name'])?>" required></div>
<div class="field"><label>ইমেইল</label><input class="input" value="<?=e($U['email'])?>" disabled></div>
<div class="field"><label>মোবাইল</label><input class="input" name="phone" value="<?=e($U['phone'])?>"></div>
<div class="field"><label>নতুন পাসওয়ার্ড (ঐচ্ছিক, ৬+)</label><input class="input" type="password" name="new_password"></div>
<button class="btn">সেভ</button>
</form></div>
<?php require __DIR__.'/_footer.php';
