我有以下形式,它允許用戶選擇一個酒店預訂日期/房間。將表單變量傳遞到一個URL與PHP
<form action="booking-form.php" method="post">
<fieldset>
<div class="select-date">
<label>Arrival Date</label>
<select name="arrd" class="day">
<option value="1" >1</option>
... snip ...
<option value="24" selected="selected">24</option>
</select>
<select name="arrm" class="month">
<option value="01" >January</option>
... snip ...
<option value="11" selected="selected">November</option>
</select>
<select name="arry" class="year">
<option value="2009" selected="selected">2009</option>
... snip ...
</select>
</div>
<div class="more">
<div class="info">
<label>Days</label>
<select name="days">
<option value="1">01</option>
... snip ...
<option value="7" selected="selected">07</option>
</select>
</div>
<div class="info">
<label>Rooms</label>
<select name="rooms">
<option value="1">01</option>
... snip ...
</select>
</div>
</div>
<input type="submit" value="Check availabilty"/>
<input type="hidden" name="submitted" value="TRUE"/>
</fieldset>
</form>
這是應該處理從表單傳遞的變量並將它們通過url傳遞給預訂提供程序的php。 當表單僅提交一個沒有錯誤的白色屏幕時,沒有任何反應。
<?php
ini_set ('display_errors',1);
error_reporting (E_ALL & ~ E_NOTICE);
if (isset($_POST['submitted'])){
$errors = array();
// A bunch of if's for all the fields and the error messages.
if (empty($_POST['arrd'])) {
$errors[] = 'Please select a day';
} else{
$arrd = ($_POST['arrd']);
}
if (empty($_POST['arrm'])) {
$errors[] = 'Please select a month';
} else{
$arrm = ($_POST['arrm']);
}
if (empty($_POST['arry'])) {
$errors[] = 'Please select a year';
} else{
$arry = ($_POST['arry']);
}
if (empty($_POST['non'])) {
$errors[] = 'Please choose a number of nights';
} else{
$non = ($_POST['non']);
}
if (empty($_POST['norooms'])) {
$errors[] = 'Please choose a number of rooms';
} else{
$norooms = ($_POST['norooms']);
}
if (empty($errors)){
$arrdate = $arrd . " " . $arrm ."" . $arry;
$url ="https://portals.uk.rezlynx.net/DHPPORTAL/wfrmpakquery.aspx?SiteID=DHOLDHALL&arrdate=$arrdate&non=$non&norooms=$norooms";
header('Location: $url');
exit();
}
else{
foreach($errors as $msg){
echo"-msg<br/>\n";
}
}
?>
任何人都可以看到我失蹤了嗎?
在此先感謝..
丹
嘗試var_dump($ _ POST); – Greg 2009-11-17 12:26:32