说实话,我对PHP一无所知,但我可以看到它的强大,我只是想学习如何控制它。我有一个三页的预订表格。第一到第二页可以正常工作,但第二到第三页不能正常工作。这是第二页的 PHP 代码 -
<?php
// Total Number of Nights Between Picked Dates
$days = (strtotime($_POST["checkoutdate"]) - strtotime($_POST["checkindate"])) / 86400 - 1;
// Extra Nightly Cost
define ("extranights", 80);
$addnights = (int)extranights * ($days - 4);
// Deposit Price Calculation
define("deposit", 370);
$deposit = null;
if (isset($_POST["numberofpeople"])) {
$numberofpeople = intval($_POST["numberofpeople"]);
$deposit = ((int)deposit * $numberofpeople + $addnights) * 0.3;
}
// Total Price Calculation
define("totalprice", 370);
$result = null;
if (isset($_POST["numberofpeople"])) {
$numberofpeople = intval($_POST["numberofpeople"]);
$result = (int)totalprice * $numberofpeople + $addnights;
}
?>
然后我在同一页面上呼应了 deposit 和 totalprice 的值
<table>
<tr>
<td width="573" height="30" align="right" valign="bottom" style="color:#0099FF;">( confirm reservation ) 30% Deposit :</td>
<td width="158" align="left" valign="bottom" style="color:#0099FF; font-size:1.8em; line-height:23px;">€<?php echo $deposit; ?></td>
</tr>
<tr>
<td height="30" align="right" valign="bottom" style="color:#0099FF;">Total Price :</td>
<td align="left" valign="bottom" style="color:#0099FF; font-size:1.8em; line-height:23px;">€<?php echo $result; ?></td>
</tr>
<td width="131" align="right" valign="middle" style="color:#000;"><input type="submit" name="submit" id="formbtn" value="CONTINUE" /></td>
</table>
我一直在苦恼的是如何将存款和总价的回声值发布到第三页上。如果解决方案/答案很广泛,那么我将不得不回到绘图板并一点一点地重新开始。但这将完成表单的用户端。我不期待数据库的东西:(