需要验证PHP中的表单而不是Javascript吗?

Hai.. i already added javascript validation for my form.Its working fine.But mean while i ve to validate the same form using PHP also.

This is the form code:

  class airportclass{
    function add_airport_frm(){
    $errmsg=0;
<table>
  <form action="" method="post" name="airport" >
  <tr> <td colspan="2" align="center"><?php echo $errmsg; ?></td></tr>

    <tr>
      <td><strong>Code :</strong></td>
      <td><input type="text" name="code" id="code"   /></td>
    </tr>
    <tr>
      <td><strong>Name:</strong></td>
      <td><input type="text" name="name" id="name"   /></td>
    </tr>
    </form>
</table>        
    }

This is the PHP script in another file :

 if(isset($_POST['postcode']) && $_POST['postcode']!="")
{
$code=$_POST['code'];
$name=$_POST['name'];
$postcode=$_POST['postcode'];
$auth=$_POST['auth'];

 if(trim($code)=='')
   {
      $errmsg = 'Please enter code';
   }

}

But its not working. Only javascript validation is working.PHP validation is not working.

Can any one suggest me????

As the form action="" is blank, the form is being posted to the same file. You indicated that you have your validation script in another file!

The $errmsg variable you're using is not global. It needs to be global if you intent to use it inside multiple functions.

You are checking against 'postcode', but postcode is nowhere set in your form.