0

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????

2
  • Could you include the html form you are trying to validate? Commented Jul 28, 2010 at 6:35
  • And what does it exactly mean "not working"? Commented Jul 28, 2010 at 6:39

3 Answers 3

1

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!

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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

1 Comment

There are more fields in the HTML form.For this snippet i have inlcuded few fields alone.Postcode field is there. PHP validation is not working If i put validation in javascript , its working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.