title: submit form automatically only once
body: <p>I have made a form which I need to self submit automatically when page is opened.
  I have tried this javascript code but what it does it creates a loop where form is submitted unlimited time without stop. I need the code where form would be submitted only once when page is opened. Please give me an advice.</p>
  
  <pre><code>&lt;form id="form" action="form.php" method="POST" &gt;
    &lt;select id="main" name="main"&gt;
      &lt;option value="1" &lt;?php if (@$_POST['main']=='1') {echo "selected='selected'"; } ?&gt;&gt;One&lt;/option&gt;
      &lt;option value="2" &lt;?php if (@$_POST['main']=='2') {echo "selected='selected'"; } ?&gt;&gt;Two&lt;/option&gt;
    &lt;/select&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
    document.getElementById("form").submit();
  &lt;/script&gt;
  </code></pre>