jquery validation, data is not saved in database
<p>I have here a code of inserting a data in database, its working and doesn't have an error, but when i put my jquery code for validation of the data, my php code for inserting the data into my database is not working, can you please check my code. Thanks!</p>

<p>Here's my php code: <code>index.php</code></p>

<pre><code>&lt;form id="FormToValidate" action="insert.php" method="POST"&gt;
  &lt;div id="content"&gt;
    &lt;p&gt;
      &lt;input type="text" name="csname" id="csname" style="width:250px" margin-bottom="3px"/&gt;
         &lt;/p&gt;
        &lt;p&gt;
          &lt;select name="units" style="width:254px"&gt;
            &lt;option value="option"&gt;option&lt;/option&gt;
           &lt;/option&gt;
            &lt;option value="option"&gt;option&lt;/option&gt;
&lt;/option&gt;

          &lt;/select&gt;
        &lt;/p&gt;
        &lt;p&gt;
          &lt;input type="text" name="color" id="color" style="width:250px"/&gt;
        &lt;/p&gt;


      &lt;p&gt;
        &lt;input type="text" name="consticker" id="consticker" style="width:250px"/&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;select name="mp" style="width:254px"&gt;
          &lt;option value="name"&gt;name&lt;/option&gt;

        &lt;/select&gt;
      &lt;/p&gt;
        &lt;p&gt;
          &lt;select name="grm" style="width:254px"&gt;
            &lt;option value="name"&gt;name&lt;/option&gt;

          &lt;/select&gt;
        &lt;/p&gt;
        &lt;p&gt;&lt;select name="typeoftransact" style="width:254px"&gt;
&lt;option value="type"&gt;type&lt;/option&gt;

&lt;/select&gt;&lt;/p&gt;
      &lt;p&gt;
        &lt;input name="dp" type="dp" style="width:250px" /&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;input name="amount" type="amount" style="width:250px" /&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;input name="dirate" type="dirate" style="width:250px" /&gt;
      &lt;/p&gt;
      &lt;p align="right"&gt;AMNT PAID: &lt;/p&gt;
&lt;p&gt;NEXT&lt;/p&gt;
&lt;/div&gt;

    &lt;div id="secondary"&gt;
      &lt;p&gt;VSI No.:&lt;/p&gt;
        &lt;p&gt;DATE:&lt;/p&gt;
        &lt;p&gt;&amp;nbsp; &lt;/p&gt;
      &lt;p&gt;TYPE OF SUBSIDY 1:&lt;/p&gt;
        &lt;p&gt;TYPE OF SUBSIDY 2:&lt;/p&gt;
        &lt;p&gt;TYPE OF SUBSIDY 3:&lt;/p&gt;
        &lt;p&gt;TYPE OF SUBSIDY 4:&lt;/p&gt;
        &lt;p&gt;TYPE OF SUBSIDY 5:&lt;/p&gt;
        &lt;p&gt;CHATTEL MORTGAGE:&lt;/p&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
        &lt;p&gt;
          &lt;input name="chapaid" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
&lt;/div&gt;
    &lt;div id="third"&gt;
      &lt;p&gt;
        &lt;input type="text" name="vsi" id="vsi" style="width:180px"/&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;input type="text" name="date" id="date" style="width:180px"/&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
  &lt;select name="type1" style="width:180px"&gt;
    &lt;option value="option"&gt;option&lt;/option&gt;
  &lt;/select&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;select name="type2" style="width:180px"&gt;
   &lt;option value="option"&gt;option&lt;/option&gt;
  &lt;/select&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;select name="type3" style="width:180px"&gt;
    &lt;option value="option"&gt;option&lt;/option&gt;
  &lt;/select&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;select name="type4" style="width:180px"&gt;
    &lt;option value="option"&gt;option&lt;/option&gt;
  &lt;/select&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;select name="type5" style="width:180px"&gt;
    &lt;option value="option"&gt;option&lt;/option&gt;
  &lt;/select&gt;
&lt;/p&gt;
        &lt;p&gt;FREE: 
          &lt;input name="chafree" type="text" style="width:100px" /&gt;
        &lt;/p&gt;
&lt;/div&gt;
&lt;div id="fourth"&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
    &lt;p&gt;&amp;nbsp;&lt;/p&gt;
    &lt;p&gt;Php: 
      &lt;input name="type1amount" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
        &lt;p&gt;Php:
          &lt;input name="type2amount" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
        &lt;p&gt;Php:
          &lt;input name="type3amount" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
        &lt;p&gt;Php:
          &lt;input name="type4amount" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
        &lt;p&gt;Php:
          &lt;input name="type5amount" type="text" style="width:120px" /&gt;
        &lt;/p&gt;
    &lt;p&gt;COST: 
      &lt;input name="chacost" type="text" style="width:120px" /&gt;
    &lt;/p&gt;
        &lt;p&gt;&amp;nbsp;&lt;/p&gt;

    &lt;p align="right"&gt;&lt;input class="small button blue" name="Save" type="submit" id="Save" value="Save" /&gt;&lt;/p&gt;


&lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>and here is my function, <code>insert.php</code></p>

<pre><code>&lt;?php
include("connection.php");

$vsi = $_POST["vsi"];
$date = $_POST["date"];
$custname = $_POST["csname"];
$unit = $_POST["units"];
$color = $_POST["color"];
$consticker = $_POST["consticker"];

$mp = $_POST["mp"];
$grm = $_POST["grm"];
$typetrans = $_POST["typeoftransact"];
$dp = $_POST["dp"];
$amount = $_POST["amount"];
$dirate = $_POST["dirate"];
$typesub1 = $_POST["type1"];
$typesub2 = $_POST["type2"];
$typesub3 = $_POST["type3"];
$typesub4 = $_POST["type4"];
$typesub5 = $_POST["type5"];
$chacost = $_POST["chacost"];
$chapaid = $_POST["chapaid"];
$chafree = $_POST["chafree"];
$type1amount = $_POST["type1amount"];
$type2amount = $_POST["type2amount"];
$type3amount = $_POST["type3amount"];
$type4amount = $_POST["type4amount"];
$type5amount = $_POST["type5amount"];

if($_POST["Save"]=="Save")
{
$query="INSERT INTO accounts (vsi,date,cname,unit,color,consticker,typetrans,downpayment,amountfinanced,dirate,mp,grm,typesub1,typesub2,typesub3,typesub4,typesub5,chapaid,chacost,chafree,type1amount,type2amount,type3amount,type4amount,type5amount)
VALUES
('".$vsi."','".$date."','".$custname."','".$unit."','".$color."','".$consticker."','".$typetrans."','".$dp."','".$amount."','".$dirate."','".$mp."','".$grm."','".$typesub1."','".$typesub2."','".$typesub3."','".$typesub4."','".$typesub5."','".$chapaid."','".$chacost."','".$chafree."','".$type1amount."','".$type2amount."','".$type3amount."','".$type4amount."','".$type5amount."');";

(mysql_query($query))

or die ("error!".mysql_error() );

}

header('Location: index.php');

?&gt;
</code></pre>

<p>If i put this jquery code, my php code did not work, but if not, its works fine,
here's my <code>jquery script</code>:</p>

<pre><code>&lt;script src="Scripts/jquery-1.6.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="Scripts/jquery-ui-1.8.13.custom.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="Scripts/jquery.validate.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="Scripts/jquery.validate.wrapper.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;script type="text/javascript" language="javascript"&gt;

    $(document).ready(function () {
        // 1. prepare the validation rules and messages.
        var rules = {
            vsi: {
                required: true,
                minlength: 7
            },
            date: "required",
            csname: "required",
            color: "required"
        };
        var messages = {
            vsi: {
                required: "VSI Number must be Inputted.",
                minlength: "VSI Number should be atleast 7 numbers."
            },
            date: "Date is requried",
            csname: "Customer Name is required",
             color: "Color is required"
        };

        // 2. Initiate the validator
        var validator
            = new jQueryValidatorWrapper("FormToValidate",
                rules, messages);

        // 3. Set the click event to do the validation
        $("#Save").click(function ()
                     {
                        if (!validator.validate())
                           {
                             return;
                            }
                        $('#FormToValidate').submit();
                         alert("Data Saved!");
                          return;

                    });
    });

&lt;/script&gt;
</code></pre>
