這裏是我的代碼,我試圖將from和to的值發回到同一頁面。在頁面的頂部,我有這樣的代碼:(它總是回聲「中的其他循環」,我不明白什麼是錯的這個簡單的事情。)未在php中發送隱藏變量
if ($_POST['ok'])
{
if (isset($_GET['from']))
{
$tmp_fromdate=$_GET['from'];
$tmp_todate=$_GET['to'];
echo "in if loop<br/>";
echo $tmp_fromdate. " ". $tmp_todate."<br/>";
$from_date=date("Y-m-d", strtotime($tmp_fromdate));
$to_date=date("Y-m-d", strtotime($tmp_todate));
echo $from_date. " ". $to_date."<br/>";
$fdate=date("F d Y", strtotime($tmp_fromdate));
$tdate=date("F d Y", strtotime($tmptodate));
}
else
{
echo "in else loop<br/>";
$start_date='2010-08-01';
$end_date=date ("Y-m-d");
$sdate=date("F d Y", strtotime($start_date));
$edate=date("F d Y", strtotime($end_date));
}
}
<form id="form1" name="form1" method="post">
<div class="demo">
<label for="from">From</label>
<span id="sprytextfield1">
<input type="text" id="from" name="from" />
<span class="textfieldRequiredMsg">mm/dd/yyyy format only.</span>
</span>
<label for="to">to</label>
<span id="sprytextfield2">
<input type="text" id="to" name="to" />
<span class="textfieldRequiredMsg">mm/dd/yyyy format only.</span>
</span>
<input type="submit" id="ok" name= "ok" value="Change Dates"/>
<input type="hidden" name="from" VALUE="<? echo($from);?>"/>
<input type="hidden" name="to" VALUE="<? echo($to);?>"/>
</div>
</form>
'<?回聲...?>似乎是非常直觀的。如果你打算使用[短標籤](http://www.php.net/manual/en/ini.core.php#ini.short-open-tag),爲什麼不使用更易讀的<'?=...?> '形式? – 2010-09-21 18:05:57
事實證明,我必須用代替 ?>代碼的每一部分,並且一切都很好。感謝提示丹尼爾。 – 2010-09-21 18:23:59