title: Form Posts Every Time Page Reloads
body: <p>Can someone help me out as i'm quite new to coding.</p>
  
  <p>I'm using smarty template engine and i have this form that is for users to update they're cover image or add one but my problem is that every time i or a user reloads the page the form posts a new image everytime without even pressing submit button.</p>
  
  <p>Here is the form.</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" id="cover_upload"&gt;
      &lt;input type="file" name="cover_file" id="file" class="cover_input" /&gt;           
      &lt;input type="hidden" name="action" value="change_cover" /&gt;
      &lt;a class="submit_form_button" style="float:right" onclick="jQuery('#cover_upload').submit();" href="javascript:void(0);"&gt;Change&lt;/a&gt;
  &lt;/form&gt;  
  </code></pre>
  
  <p>And here is the php</p>
  
  <pre><code>if (isset($action) &amp;&amp; $action=='change_cover' &amp;&amp; isset($_SESSION['loggeduser_id'])){
      if (isset($_FILES['cover_file']['name']) &amp;&amp; $_FILES['cover_file']['name']){
          if (($_FILES["cover_file"]["type"] == "image/gif") || ($_FILES["cover_file"]["type"] == "image/jpeg") || ($_FILES["cover_file"]["type"] == "image/pjpeg") || ($_FILES["cover_file"]["type"] == "image/png")){
              $filename = $_SESSION['loggeduser_id']."_".date("YmdHis").".jpg";
              if (move_uploaded_file($_FILES["cover_file"]["tmp_name"],"$basepath/thumbs/users/covers/" . $filename)){
                  $user = new User();
                  $user-&gt;update($_SESSION['loggeduser_id'],array("cover" =&gt; $filename));
                  $_SESSION['loggeduser_details']['cover'] = $filename;
              }
          }
      }
  }
  </code></pre>
  
  <p>Could someone please show or tell me what is going on and how to fix this thanks</p>