GP | fix: починил форму + скрытое хранение кридов

This commit is contained in:
User A1005044
2024-07-17 06:59:36 +03:00
parent a1760adfa3
commit 64fb520316
3 changed files with 18 additions and 22 deletions

View File

@@ -28,29 +28,20 @@ const CHAT_ID = '';
[...modalForms, ...callbackForms].forEach((form) => {
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);
// });
// }
});