Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
<input id = "NumberOfGame" disabled hidden required> <input minlength="6" maxlength="6" id = "YourPassword" hidden required>
if(!empty($_POST['numberOfGame'] )){echo 'Если numberOfGame не пустой, то...';}
<script src="script.js"></script> <input id = "NumberOfGame" disabled hidden required> <input minlength="6" maxlength="6" id = "YourPassword" hidden required> <button id = "send" hidden>Создать</button>
window.onload = () => { document.getElementById('send').addEventListener('click', () => { const numberOfGame = document.getElementById('NumberOfGame').value; const yourPassword = document.getElementById('YourPassword').value; const link = 'matches.txt'; const xhr = new XMLHttpRequest(); xhr.open('POST', link); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(`numberOfGame=${numberOfGame}&yourPassword=${yourPassword}`); xhr.onload = () => { if (xhr.status !== 200) console.log(`Error ${xhr.status}: ${xhr.statusText}`) }; xhr.onerror = () => { console.log('Request failed') }; return false }) };
<?php if(!empty($_POST['numberOfGame']) and !empty($_POST['yourPassword'])) { $file = 'matches.txt'; $current = file_get_contents($file); $current = "(".$_POST['numberOfGame'].";".$_POST['yourPassword'].")"; file_put_contents($file, $current); }
const link = 'matches.txt';