The site has a button (Create page) and input is next to it:
The code is:
<a class="sidebar-toggle" > <button style="background:transparent; border: 0; ">Создать страницу: </button> <input style="background: #3e95c7; border: 0; outline:none;" type="text" value=""> </a> By pressing the button, by the way, it is not enclosed in the <form> , I save the contents of <div class="getcode">некий текст</div> on the server as an html file: 
The mechanism for sending content to the handler on JS:
var button = document.querySelector("button"); button.addEventListener("click", sendSave, false); function sendSave() { var data = document.querySelectorAll(".getcode"); var formData = new FormData(); for (var i = 0; i < data.length; i += 1) { formData.append("data[]", data[i].innerHTML); } var XHR = "onload" in new XMLHttpRequest() ? XMLHttpRequest : XDomainRequest; var xhr = new XHR(); xhr.open('POST', 'save.php', true); xhr.onreadystatechange = () => { if (xhr.readyState !== 4) { return; } if (xhr.status === 200) { console.log(xhr.responseText); } }; xhr.send(formData); } Next on the server data is captured and placed in a file with the following php code:
<?php $fp = fopen(date('Ymdhis').'-data.html', 'w'); $html = ""; foreach($_POST[data] as $data) { $html .= $data.PHP_EOL; } echo (fwrite($fp, $html)) ? "Сохранено" : "Не сохранено"; fclose($fp); ?> The file name is automatically generated, so that the file name is captured from inputa when saved and transferred to the handler at the touch of a button and entered instead of the currently generated current date:


$fileName = $_POST['input_name'];- rjhdby