not able to run function in php : <p>I'am not able to run a function in php oops concept.
My data gets inserted without checking the validation code in check_data().
My form directly points to insert_payment_cash() function.</p>

<pre><code>function check_data()
            {
                $error =0;
                $balance = ($_POST["pay_amount"])-($_POST["cash_amount"]);
                $invoice_id = $_POST["id"];
                if($_POST["cash_amount"]&gt;$_POST["pay_amount"])
                {
                    $_SESSION['message'] = "Amount cannot be greater than pay amount&lt;br&gt;";
                    $error=1;
                }
                else if($balance == 0 &amp;&amp; $_POST["penalty"] &gt; 0)
                {
                    $_SESSION['message'] .= "If balance is zero(0), penalty will no be applied";
                    $error =1;
                }
                if($error == 1)
                {
                    header("location:../payment_details.php?id=$invoice_id");
                }
            }
            function insert_payment_cash()
            {
                $this-&gt;check_data();
                #rest insertion code 
    }
</code></pre>
