title: Button To Download .txt File (PHP & HTML)
body: <p>Ok so I want to my users to be able to download a <code>.txt</code> file with their username on it.</p>
  
  <p>I've checked everywhere, and so far I can't find what I want or if it's even possible.</p>
  
  <p>To give you an example of what I'm trying to do, here is my code:</p>
  
  <pre><code>&lt;button type="button"&gt;Download All Your Keys On A .txt
  &lt;?php
  $file = 'logs/$session-&gt;username.txt';
  
  if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist.");
  
  $type = filetype($file); // Get a date and timestamp $today = date("F j, Y, g:i a"); $time = time(); // Send file headers header("Content-type: $type"); header("Content-Disposition: attachment;filename=$filename");
  header("Content-Transfer-Encoding: binary"); 
  header('Pragma: no-cache'); 
  header('Expires: 0'); // Send the file contents.
  set_time_limit(0); 
  readfile($file);
  ?&gt;
  &lt;/button&gt;
  </code></pre>
  
  <p>I'm trying to make it so that when you click the button, it force download's the .txt file configured with:</p>
  
  <pre><code>$file = 'logs/$session-&gt;username.txt';
  </code></pre>
  
  <p>Sorry if this is confusing and messy, but there's no other way for me to present this.</p>
  
  <p>Thanks in advance!</p>