无法将输入传递给变量。我的HTML是
<form id="checkform" action="DateTest.php" method = "post">
From Date:<label for="date"></label><br />
<input id="date" type = "date" name = "date" placeholder = "Date" autocomplete="off" /><br />
Until Date:<label for="date1"></label><br />
<input id="date1" type = "date" name = "date1" placeholder = "Date" autocomplete="off" /><br />
<input class="submit" title="submit" type = "submit" value = "Submit" name = "Submit"/><br />
</form>
</div>
我的php是
<?php
$fromDate = isset($_POST['date']) ? $_POST['date'] : 0;
$toDate = isset($_POST['date1']) ? $_POST['date1'] : 0;
var_dump($fromDate);
var_dump($toDate);
$dateMonthYearArr = array();
$fromDateTS = strtotime($fromDate);
$toDateTS = strtotime($toDate);
for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) {
$currentDateStr = date("d-m-Y",$currentDateTS);
$dateMonthYearArr[] = $currentDateStr;
}
echo "<pre>";
print_r($dateMonthYearArr);
echo "</pre>";
?>
这是打印一个空数组,所以我在转移后转储,它显示$fromDate
按照指示传递但显示$toDate
为空整数。
答案 0 :(得分:0)
早上好了,没有改变一件事,一定是个小故障。