I know this is frequently asked question however I am trying to add some code on existing, rest all POST are working fine, just what I am adding is not, I have tried most of the steps but of no use, Error Message I am getting
Notice: Undefined index: pay_date_from in C:\xampp\htdocs\water_inventory\production\fetch_Cust_WaterBillPay.php on line 19
Notice: Undefined index: pay_date_from_to in C:\xampp\htdocs\water_inventory\production\fetch_Cust_WaterBillPay.php on line 21
here is my code:
<form id="demo-form2" class="form-horizontal form-label-left" action="fetch_Cust_WaterBillPay.php" method="POST">
<div class="form-group">
<label class="col-md-2">Pay Date From </label>
<div class="col-md-3">
<input type="date" id="pay_date_from" name="pay_date_from" class="form-control col-md-7 col-xs-12">
</div>
<label class="col-md-2">To</label>
<div class="col-md-3">
<input type="date" id="pay_date_to" placeholder="Enter Current Reading" name="pay_date_from_to" class="form-control col-md-7 col-xs-12">
</div>
<div class="col-md-2">
<input type="submit" class="btn btn-block btn-primary searchDept" style="margin-left: 3%;" value="Search"></div>
</div>
<br><hr>
<div id="result"></div><div style="clear:both"></div>
</form>
My fetch_Cust_WaterBillPay.php:
<?php
session_start();
include './chklog.php';
include './db_config.php';
if ((!isset($_SESSION['first_name']) == true)) {
unset($_SESSION['first_name']);
}
$logged = $_SESSION['first_name'];
if(isset($_POST['submit']))
{
//if(isset($_POST['pay_date_from']))//Tried these
$pay_from=$_POST['pay_date_from'];
//if(isset($_POST['pay_date_from_to']))
$pay_to=$_POST['pay_date_from_to'];
$branch_name = $_SESSION['branch_name'];
}
?>
Getting error on this line:
<?php
$res1 =mysqli_query($con, "SELECT cust_id,customer_name,meter_no,created_on,invoice_month,invoice_no,amount_paying,mode_of_payment FROM `wb_customer_payment` WHERE branch_name='$branch_name' and created_on>='$pay_from' and created_on<='$pay_to' order by created_on desc");//Getting error here
while($data = mysqli_fetch_array($res1))
{
echo "<tr>"
. "<td>".$data['customer_name']."</td>"
. "<td>".$data['meter_no']."</td>"
. "<td>".$data['created_on']."</td>"
. "<td>".$data['invoice_month']."</td>"
. "<td>".$data['invoice_no']."</td>"
. "<td>".$data['amount_paying']."</td>"
. "<td>".$data['mode_of_payment']."</td>"
. "<td> <a href='water_bill_detail.php?cust_id=".$data["cust_id"]."' class='btn btn-primary btn-xs' role='button'><i class='fa fa-user'></i> Details</a></td>"
. "</tr>";
}
?>
UPDATE:
I declared variable just before checking empty
$pay_from='';
$pay_to='';
However , now no error however I am not getting values. Even URL doesn't have values passed.
I am not sure what have I am missing. Thanks