title: select box value changes on form reloading with php validation
body: <p>I need a solution for this. Here I want to validate form elements. I did it with PHP but what my problem is on clicking submit button validation process takes place but <strong>select box value changes to select dept</strong>.
  FOR EXAMPLE, if you just click submit button without giving student <code>id</code> by only <code>select dept..</code> the message shows enter <code>studentid</code> but select box value changes to <code>select dept</code> again as it page reloads first..</p>
  
  <p>php:</p>
  
  <pre><code>if($_POST['submit']!='')
  {
      $c=0;
      if($_POST['studid']=='' ) {
          $msg_id="Enter stud id";
          $c++;
      }
      if($_POST[studdept]=='') {
          $msg_dept="Enter stud dept";
          $c++;
      }
      if($c==0) {
          echo "form has been submitted..";
      }
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="myform" action="" method="post"&gt;
      &lt;table&gt;
          &lt;tr&gt;
          &lt;td&gt; Studid: *&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="studid" maxlength="10" value="&lt;?=$_POST[studid]?&gt;"&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $msg_id; ?&gt; &lt;/td&gt; &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt; StudDept: *&lt;/td&gt;
              &lt;td&gt;
                  &lt;select name="studdept"&gt;
                      &lt;option value="" selected="selected" &gt;select dept&lt;/option&gt;
                      &lt;option value="cse" &gt;cse&lt;/option&gt;
                      &lt;option value="eee" &gt;eee&lt;/option&gt;
                      &lt;option value="mech" &gt;mech&lt;/option&gt;
                      &lt;option value="ece" &gt;ece&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;?php echo $msg_dept; ?&gt; &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" name="submit" value="submit"&gt; &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>can someone help me here?</p>
  
  <p>Thanks in Advance...</p>