<?php
/* https://api.telegram.org/bot7XXX5XXXXXXXXXXXXXXXXXXXXXwXXXOY4UXXX/getUpdates,
где, XXXXXXXXXXXXXXXXXXXXXXX - токен вашего бота, полученный ранее */
$name = $_POST['user_name'];
$phone = $_POST['user_phone'];
$email = $_POST['user_email'];
$token = "XXXXX";
$chat_id = "-XXXXXX";
$arr = array(
'Имя пользователя: ' => $name,
'Телефон: ' => $phone,
'Email' => $email
);
foreach($arr as $key => $value) {
$txt .= "<b>".$key."</b> ";
};
$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
if ($sendToTelegram) {
header('Location: thank-you.html');
} else {
echo "Error";
}
?>