<p>Значение 1 <input id="1" value="12345"></p>
<p>Значение 2 <input id="2" value="54321"></p>
<?php
$file = 'data.txt';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$a = $_POST['a'] ?? null;
$b = $_POST['b'] ?? null;
if (isset($a, $b)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . mb_strlen("$a\n$b"));
exit("$a\n$b");
} else {
exit('Оба поля обязательны для заполнения!');
}
}
?>
<form method="post">
<p>Значение 1 <input type="text" name="a" placeholder="12345"></p>
<p>Значение 2 <input type="text" name="b" placeholder="54321"></p>
<p><input type="submit"></p>
</form>