-1
我有形式和PHP,表單詢問用戶他想要購買什麼,用戶選擇它並添加它,我希望它,以便當點擊提交按鈕時,數據存儲在提交按鈕下面顯示了php的可變參數,但我不知道該怎麼做!窗體在PHP和提交按鈕?
<p><b>Billing Information</b></p>
<form action="" method="get">
<p>Name:
<input type="text" name="firstname">
<br>
<strong>Items:</strong></p>
</form>
<form id="form1" method="post" action="">
<p>
<input type="checkbox" name="one" value= "2.39"/>
<label for="one">Four 100-watt light bulbs for $2.39</label>
<p>
<input type="checkbox" name="two" value= "4.29"/>
<label for="two">Eight 100-watt light bulbs for $4.29</label>
<p>
<input type="checkbox" name="three" value= "3.95"/>
<label for="three">Four 100-watt long-life light bulbs for $3.95</label>
</p>
<p>
<input type="checkbox" name="four" value= "7.49"/>
<label for="four">Eight 100-watt long-life light bulbs for $7.49</label>
</p>
<input name="battery" name = "battery" type="number" id="battery" size="1" maxlength="3" />
<label for="battery">Battery Packs Checkbox $10.42 each:</label>
</p>
<p><strong><b>Card Details</b>:</strong></p>
<p>
<?php
if(isset($_POST['value']))
{
$one = $_POST['one'];
$two = $_POST['two'];
$three = $_POST['three'];
$four = $_POST['four'];
$five = $_POST['battery'];
$total = $one + $two + $three + $four + $battery;
$interest = $total * 0.175;
echo "Total cost is " .$total;
}
?>
</p>
<p>
<p>
<input name="Visa" type="radio" value= <?php $cardone = "Visa"; ?>
<p>Visa</p>
<p>
<input name="Mastercard" type="radio" value= <?php $cardtwo = "Mastercard"; ?>
<p>Mastercard</p>
<p>
<input name="American" type="radio" value=<?php $cardthree = "American Express"; ?>
<p> American Express </p>
<p>
<?php
if(isset($_POST['value']))
{
$cardone = $_POST['cardone'];
$cardtwo = $_POST['cardtwo'];
$cardthree = $_POST['cardthree'];
$total = $cardone + $cardtwo + $cardthree;
echo "You have chose to pay using a " .$total;
}
?>
<input type="Submit" name="SubmitForm" value="Submit">
<form action="Results.php" method="post">
<input name="Submit" type="button" />
</p>
</form>
對不起,如果這沒有出來好,但HTML的東西不是很好。請幫幫我!
您必須將表單提交到新頁面,否則無法從同一頁面上的值獲取'$ _POST'。 – 2013-03-17 16:03:00
'$ _POST ['cardone']是什麼?這個名字沒有表單字段,名字是'Mastercard'。爲什麼要添加這些字段,它們不是數字? – Barmar 2013-03-17 16:03:04
首先,你有''OUTSIDE你的'