diff --git a/.secrets.php b/.secrets.php new file mode 100644 index 0000000..29a08ce --- /dev/null +++ b/.secrets.php @@ -0,0 +1,3 @@ + { form.addEventListener('submit', (event) => { event.preventDefault(); - const formData = new FormData(event.currentTarget); - const name = formData.get('name'); - const phone = formData.get('phone'); + const formData = new FormData(event.currentTarget); // автоматически формирует объект с полями и значениями + formData.append('act', 'order'); // добавляем поле для проверки на бекенде + + // const name = formData.get('name'); + // const phone = formData.get('phone'); // const message = `Имя: ${name} Телефон ${phone}`; - // sendMessage(message); + event.currentTarget.reset(); fetch('../../send.php', { method: 'POST', - data: { name, phone }, + cache: 'no-cache', + body: formData, }); if (callbackModal) callbackModal.classList.remove('active'); if (thanksModal) thanksModal.classList.add('active'); }); -}); - -// function sendMessage(message) { -// const url = `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&parse_mode=html&text=${message}`; - -// fetch(url) -// .then((data) => { -// console.log('Message sent successfully:', data); -// }) -// .catch((error) => { -// console.error('Error sending message:', error); -// }); -// } +}); \ No newline at end of file diff --git a/send.php b/send.php index 358640c..5cff261 100644 --- a/send.php +++ b/send.php @@ -1,7 +1,9 @@