lundi 4 avril 2016

Error in form submission

I have a form where I have the following two input fields -

The second input field (date field) is hidden by default. If user checks the 'checkbox' then it shows up and user can select a date.

I've written my INSERT query in the following way for this form -

 if(isset($_POST['cheque'])) 
    {
       $qry = mysqli_query($con, "INSERT INTO `disburse_payment`(`trans_id`, `payment_date`, `supplier_id`, `finance_id`, `amount`, `cheque`, `cheque_date`, `voucher`, `bearer`, `note`, `entry_date`) VALUES (NULL, '$payment_date', '$supplier_id', '$finance_id', '$amount', '$cheque', '$cheque_date', '$voucher', '$bearer', '$note', NOW())"); 
    } else 
    {
        $qry = mysqli_query($con, "INSERT INTO `disburse_payment`(`trans_id`, `payment_date`, `supplier_id`, `finance_id`, `amount`, `cheque`, `cheque_date`, `voucher`, `bearer`, `note`, `entry_date`) VALUES (NULL, '$payment_date', '$supplier_id', '$finance_id', '$amount', '0', '0', '$voucher', '$bearer', '$note', NOW())");
    }

So, if the checkbox is checked then I want to execute the first query, otherwise I want to execute the second query. The second query doesn't execute. Meaning, if I submit the form with checkbox checked and with value of the date field then the query works but if I leave the checkbox unchecked, it shows me error.

I'm certain my condition here isn't working properly or I'm missing something. Any help would be much appreciated. Thanks!!!




Aucun commentaire:

Enregistrer un commentaire