我无法从文本字段'current_reading'中获取数据。可能是什么问题?每个其他文本和$_POST
方法都正常工作
索引页面
<body>
<?php
include "connect.php";
?>
<form method="post" action="billing.php">
<div id="wrapper">
<div class="data">
<div class="label">
Society
</div>
<div class="textfield">
<input type="text" name="society" />
</div>
<div class="label">
Customer id
</div>
<div class="textfield">
<input type="text" name="customer_id" />
</div>
<div class="label">
Customer name
</div>
<div class="textfield">
<input type="text" name="customer_name" />
</div>
<div class="label">
Wing
</div>
<div class="textfield">
<input type="text" name="wing" />
</div>
<div class="label">
Flat no
</div>
<div class="textfield">
<input type="text" name="flat_no" />
</div>
<div class="label">
Previous date
</div>
<div class="textfield">
<input type="text" name="previous_date" />
</div>
<div class="label">
Previous reading
</div>
<div class="textfield">
<input type="text" name="previous_reading" />
</div>
<div class="label">
Current date
</div>
<div class="textfield">
<input type="text" name="current_date" />
</div>
<div class="label">
Current reading
</div>
<div class="textfield">
***<input type="text" name="current_reading" />***
</div>
</div>
<input type="submit" name="submit" value="submit" />
</div>
</form>
</body>
</html>
开票
<body>
<?php
include "connect.php";
?>
<?php
$society=$_POST['society'];
$id=$_POST['customer_id'];
$name=$_POST['customer_name'];
$wing=$_POST['wing'];
$flat_no=$_POST['flat_no'];
$previous_reading=$_POST['previous_reading'];
$previous_date=$_POST['previous_date'];
$current_date=$_POST['current_date'];
*****$current_reading=$_POST['current_reading'];*****
if($current_reading=" ")
{
echo "current date:".$current_date."<br><br>";
}
else
{
echo "current reading:".$current_reading."<br><br>";
echo "previous reading:".$previous_reading."<br><br>";
$units=($current_reading-$previous_reading);
echo "units".$units."<br><Br>";
$rate= mysql_query("select per_unit_rate from charges where society=".$society);
$amount = $units * $rate;
$service_charge=mysql_query("select service_charge from charges where society=".$society);
$net_bill=$amount+$service_charge;
echo "The amount of net bill is:".$net_bill;
mysql_query("insert into report values ('$id', '$current_date', '$net_bill','$units')");
}
?>
<?php
include "connect.php";
?>
</body>
</html>
我无法从文本字段“当前读数”(粗体和红色)中获取数据。可能是什么问题?每个其他文本和$_POST
方法都正常工作
答案 0 :(得分:2)
更改Billing.php中的行代码
if($current_reading=" ")
{
echo "current date:".$current_date."<br><br>";
}
成为
if(empty($current_reading))
{
echo "current date:".$current_date."<br><br>";
}
希望它有效。
答案 1 :(得分:0)
尝试
if(isset($_POST['current_reading'])){
$current_reading = $_POST['current_reading'];
}else{
echo 'Current reading is not set';
}