title: PHP, HTML: Submit form automatically
body: <p>I have a PHP page with an HTML form on it. If some variables are set in the URL I would like to automatically submit the form on the page.</p>
  
  <p>IE:</p>
  
  <pre><code>if (isset($_GET['var']))
  {
    // SUBMIT FORM
  }
  else
  {
    // leave the page alone
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Here is what I have using the answer that someone provided below, but it's still not working. I would like the form to submit itself if the condition is met.</p>
  
  <pre><code>&lt;?php
  
  if ($r == 1)
  {
  
  echo "  
    &lt;br&gt;
     &lt;form action=\"bookRoom.php\" method=\"post\" id=\"dateForm\"&gt;
      &lt;input name=\"from\" type=\"hidden\" value=\"$fday/$fmonth/$fyear\"&gt;
      &lt;input name=\"to\" type=\"hidden\" value=\"$tday/$tmonth/$tyear\"&gt;
      &lt;input type=\"submit\"&gt;
     &lt;/form&gt;
  
    &lt;script type=\"text/javascript\"&gt;
      $('#dateForm').submit();
    &lt;/script&gt;
  ";      
  }
  ?&gt;
  </code></pre>