title: if php boolean is true run php script in background in html page
body: <p>I have a html/php web page, if something runs as it should my boolean is set to true. If it is set to true i want to run a php script that downloads a file for the user. Currently i have it as a button that when pressed will download the file, my button looks like this:</p>
  
  <pre><code>&lt;input type="button" value="Export CSV" onclick="window.open('bulk_out.php', '_blank')"&gt;
  
  </code></pre>
  
  <p>Is it possible to auto run the bulk_out.php if a boolean is set to true?
  I have tried to check the variable and put in a onload action, while the variable is true but no download happens.</p>
  
  <pre><code>&lt;?php
  if($worked == TRUE){
      ?&gt;
  &lt;div onload="window.open('bulk_out.php', '_blank')"&gt;CSV downloaded to your machine. &lt;/div&gt;&lt;?php }
  
  </code></pre>
  
  <p>I know $worked is set to true because the text "CSV downloaded to your machine." shows on the page.</p>