ааа - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ааа.php

  1. <?php
  2. $tg_user = '-1001981101116'; // id пользователя, которому отправиться сообщения
  3. $bot_token = '6245610714:AAFFSV5zR4UJhOpfudcTilbRQxHO2Y17Cxg'; // токен бота
  4.    
  5.   if (isset($_POST['tildaspec-formname']) && !empty($_POST['tildaspec-formname'])) {
  6.         $txt .= "Тема заявки: " . strip_tags(trim(urlencode($_POST['tildaspec-formname']))) . "\n";
  7.     }  
  8.    
  9.     if (isset($_POST['names']) && !empty($_POST['names'])) {
  10.         $txt .= "Имя: " . strip_tags(trim(urlencode($_POST['names']))) . "\n";
  11.     }
  12.    if (isset($_POST['name']) && !empty($_POST['name'])) {
  13.         $txt .= "Имя: " . strip_tags(trim(urlencode($_POST['name']))) . "\n";
  14.     }
  15.      
  16.     // Номер телефона
  17.     if (isset($_POST['phone']) && !empty($_POST['phone'])) {
  18.         $txt .= "Телефон: " . strip_tags(trim(urlencode($_POST['phone']))) . "\n";
  19.     }
  20.    
  21. $params = array(
  22.     'chat_id' => $tg_user, // id получателя сообщения
  23.     'text' => $txt, // текст сообщения
  24.     'parse_mode' => 'HTML', // режим отображения сообщения, не обязательный параметр
  25. );
  26.  
  27. $curl = curl_init();
  28. curl_setopt($curl, CURLOPT_URL, 'https://api.telegram.org/bot' . $bot_token . '/sendMessage'); // адрес api телеграмм
  29. curl_setopt($curl, CURLOPT_POST, true); // отправка данных методом POST
  30. curl_setopt($curl, CURLOPT_TIMEOUT, 10); // максимальное время выполнения запроса
  31. curl_setopt($curl, CURLOPT_POSTFIELDS, $params); // параметры запроса
  32. $result = curl_exec($curl); // запрос к api
  33. curl_close($curl);
  34.  
  35. var_dump(json_decode($result));
  36. ?>
  37.  
File Description
  • ааа
  • PHP Code
  • 28 Apr-2023
  • 1.75 Kb
You can Share it: