title: Form to run PHP script and display output on same page
body: <p>I have a PHP script which downloads email attachments on a daily basis from cron. I would like to create a HTML form which can be used to run this script and others manually when necessary. </p>
  
  <p>As the script runs there is a loop which displays the number of emails that have been run through and then at the end echos that the script has finished running. </p>
  
  <p>I would like to be able to make it so that once the button is pressed on the form, a window will display these output's so that the user knows once the script has finished running.</p>
  
  <p>The simple form I have so far:</p>
  
  <pre><code>&lt;form action="test.php" type="post"&gt;
      &lt;input type="submit" value="Download Attachments" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Is it possible to achieve this? Right now the best way I can think of doing it is to redirect back to the form page after the script has finished running, but I would prefer it if everything could be on the same page so the user has a record of what scripts they have run, right in front of them.</p>