0
我有這個代碼的工作,而現在它不輸出總,它只是始終停留在0PHP,計數多變量總
我檢查了過來,以確保世界上沒有遺漏半 - 大腸或任何東西。
我知道它非常不安全的代碼,但是我只是想讓它現在工作!
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
<link href='http://fonts.googleapis.com/css?family=Tauri' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Cantora+One' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="container">
<?php
$firstchoice=$_POST["Cases"];
$secondchoice=$_POST["CPU"];
$thirdchoice=$_POST["Motherboard"];
$fourthchoice=$_POST["HDD"];
$fifthchoice=$_POST["PSU"];
$sixthchoice=$_POST["RAM"];
$seventhchoice=$_POST["GPU"];
?>
<?php
//prices
$Casecom=12.27;
$Antec300=31.99;
$Coolermaster690 = 74.99;
$CorsairObsidian = 148.05;
$AMDAthlon450 = 32.00;
$AMDA4 = 32.00;
$AMDA10 = 95.12;
$AMDFX8350 = 166.58;
$IntelG530 = 36.99;
$Inteli3 = 90.78;
$Inteli5 = 148.14;
$GigabyteGA78LMTUSB3 = 38.99;
$ASUSSabertooth990FX = 135.50;
$BiostarH61MU3H61 = 43.98;
$AsusSABERTOOTHX79 = 263.90;
$HitachiZ5K500 = 32.54;
$WD3TB = 100.00;
$OCZ128GB = 74.68;
$OCZ240GB = 119.99;
$CoolermasterGX550W = 57.99;
$CasecomSilver500W = 99.99;
$CorsairTX650W = 131.00;
$Kingston2GBx1 = 11.00;
$Kingston2GBx2 = 20.00;
$KingstonHyperX = 14.99;
$KingstonHyperX4GB = 26.54;
$CrucialBallistix = 24.99;
$CorsairValue4GB = 27.01;
$CorsairXMS2GB = 34.57;
$Kingston8GB = 40.00;
$Corsair8GBVeng = 54.56;
$GSkill8GB = 57.54;
$CorsairXMS12GB = 67.43;
$GSKill16GB = 88.94;
$Corsair16GBVeng = 96.74;
$XFXHD6450 = 34.59;
$SapphireHD6570 = 53.67;
$PowerColorHD6870 = 89.64;
$XFXHD6870 = 124.65;
$GigabyteHD7870 = 195.75;
$KFAGT630 = 61.00;
$EVGA650SC = 94.75;
$Gigabyte650 = 133.56;
$EVGAGTX660 = 215.78;
if
($firstchoice =="Casecom CM-262 Case"){
$total_price1 = $Casecom;}
else if
($firstchoice =="Antec 300 Case"){
$total_price1 = $Antec300;}
else if
($firstchoice =="Coolermaster 690 NVIDIA Edition"){
$total_price1 = $Coolermaster690;}
else if
($firstchoice =="Corsair Obsidian 900D Case"){
$total_price1 = $CorsairObsidian;}
if
($secondchoice =="AMD Athlon II X3 450 3.2Ghz 3-Core"){
$total_price2 = $AMDAthlon450;}
else if
($secondchoice =="AMD A4 3300 2.5GHz 2-Core"){
$total_price2 = $AMDA4;}
else if
($secondchoice =="AMD A10 5800K Black Edition 3.8GHz 4-Core"){
$total_price2 = $AMDA10;}
else if
($secondchoice =="AMD FX8350 4GHz 8-Core"){
$total_price2 = $AMDFX8350;}
else if
($secondchoice =="Intel Celeron G530 Single Core"){
$total_price2 = $IntelG530;}
else if
($secondchoice =="Intel Core i3 2120 Dual Core"){
$total_price2 = $Inteli3;}
else if
($secondchoice =="Intel Core i5 2320 Quad Core"){
$total_price2 = $Inteli5;}
if
($thirdchoice =="Gigabyte GA-78LMT-USB3 760G Socket AM3+ VGA DVI HDMI 7.1 Channel Audio mATX"){
$total_price3 = $GigabyteGA78LMTUSB3;}
else if
($thirdchoice =="ASUS Sabertooth 990FX R2.0 Socket AM3+ 8 Channel Audio ATX Motherboard"){
$total_price3 = $ASUSSabertooth990FX;}
else if
($thirdchoice =="Biostar H61MU3 H61 Socket 1155 6 Channel HD Audio mATX Motherboard"){
$total_price3 = $BiostarH61MU3H61;}
else if
($thirdchoice =="Asus SABERTOOTH X79 Socket 2011 8 Channel Audio ATX Motherboard"){
$total_price3 = $AsusSABERTOOTHX79;}
if
($fourthchoice =="Hitachi 250GB Travelstar Z5K500 Internal Hard Drive"){
$total_price4 = $HitachiZ5K500;}
else if
($fourthchoice =="WD 3TB Green Desktop Drive"){
$total_price4 = $WD3TB;}
else if
($fourthchoice =="OCZ 128GB Agility 4 SSD"){
$total_price4 = $OCZ128GB;}
else if
($fourthchoice =="OCZ 240GB Agility 4 SSD"){
$total_price4 = $OCZ240GB;}
if
($fifthchoice =="Coolermaster GX 550W PSU"){
$total_price5 = $CoolermasterGX550W;}
else if
($fifthchoice =="Casecom Silver 500W PSU - With 12cm Red LED Fan"){
$total_price5 = $CasecomSilver500W;}
else if
($fifthchoice =="Corsair TX 650W PSU - 80plus Bronze Certified"){
$total_price5 = $CorsairTX650W;}
if
($sixthchoice =="Kingston 2GB DDR3 1600MHz Value Memory"){
$total_price6 = $Kingston2GBx1;}
else if
($sixthchoice =="Kingston 2x 2GB(4GB) DDR3 1600MHz Value Memory"){
$total_price6 = $Kingston2GBx2;}
else if
($sixthchoice =="Kingston 2GB DDR3 1333MHz HyperX Black Series"){
$total_price6 = $Kingston2GBx2;}
else if
($sixthchoice =="Kingston 4GB DDR3 1600MHz HyperX Black Series"){
$total_price6 = $Kingston4GB;}
else if
($sixthchoice =="Crucial 2GB DDR2 800MHz Ballistix Sport Memory"){
$total_price6 = $CrucialBallistix;}
else if
($sixthchoice =="Corsair Value 4GB (2x2GB) DDR3 1333MHz Memory"){
$total_price6 = $CorsairValue4GB;}
else if
($sixthchoice =="Corsair 2GB DDR2 800MHz XMS2 Memory"){
$total_price6 = $CorsairXMS2GB;}
else if
($sixthchoice =="Kingston 8GB DDR3 1600MHz HyperX Genesis Memory"){
$total_price6 = $Kingston8GB;}
else if
($sixthchoice =="Corsair 8GB (2X4GB) DDR3 1600Mhz RED Vengeance Memory Kit CL8 1.5V"){
$total_price6 = $Corsair8GBVeng;}
else if
($sixthchoice =="G.Skill 8GB DDR3 1600mhz Sniper Memory"){
$total_price6 = $GSkill8GB;}
else if
($sixthchoice =="Corsair 12GB DDR3 1600Mhz XMS Memory"){
$total_price6 = $CorsairXMS12GB;}
else if
($sixthchoice =="G.Skill 16GB DDR3 1600MHz RipjawsZ X79 Memory"){
$total_price6 = $GSKill16GB;}
else if
($sixthchoice =="Corsair 16GB 1600MHz Vengeance Blue Memory"){
$total_price6 = $Corsair16GBVeng;}
if
($seventhchoice =="XFX HD 6450 Core 2GB DDR3 VGA DVI HDMI PCI-E Graphics Card"){
$total_price7 = $XFXHD6450;}
else if
($seventhchoice =="Sapphire HD 6570 2GB DDR3 DVI VGA HDMI PCI-E Graphics Card"){
$total_price7 = $SapphireHD6570;}
else if
($seventhchoice =="XFX HD 6870 900MHz 1GB GDDR5 Dual DVI Dual Mini DisplayPort HDMI PCI-E Graphics"){$total_price7 = $XFXHD6870;}
else if
($seventhchoice =="Gigabyte HD 7870 OC 2048MB GDDR5 DVI HDMI Dual Mini DisplayPort PCI-E Graphics"){$total_price7 = $GigabyteHD7870;}
else if
($seventhchoice =="KFA2 GT 630 2GB DDR3 VGA DVI HDMI PCI-E Graphics Card"){$total_price7 = $KFAGT630;}
else if
($seventhchoice =="EVGA GTX 650 SuperClocked 1GB GDDR5 Dual DVI Mini HDMI PCI-E Graphics Card"){$total_price7 = $EVGA650SC;}
else if
($seventhchoice =="Gigabyte GTX 650 Ti 2GB GDDR5 5400MHz Dual DVI 1x HDMI PCI-E Graphics Card"){$total_price7 = $Gigabyte650;}
else if
($seventhchoice =="EVGA GTX 660 Ti 2048MB GDDR5 Dual DVI HDMI DisplayPort PCI-E Graphics Card"){$total_price7 = $EVGAGTX660;}
else
?>
<div id="Subtitle">
<?php
echo "Order Summary"
?>
</div>
<div id="orderSummary">
<div id="CaseItem">
<h3>Case:</h3>
<?php
echo $firstchoice;
?>
</div>
<div id="CPUItem">
<h3>CPU:</h3>
<?php
echo $secondchoice;
?>
</div>
<div id="MotherboardItem">
<h3>Motherboard:</h3>
<?php
echo $thirdchoice;
?>
</div>
<div id="HDDItem">
<h3>Hard Disk Drive</h3>
<?php
echo $fourthchoice;
?>
</div>
<div id="PowerSupplyItem">
<h3>Power Supply</h3>
<?php
echo $fifthchoice;
?>
</div>
<div id="RAMItem">
<h3>Memory (RAM)</h3>
<?php
echo $sixthchoice;
?>
</div>
<div id="GPUItem">
<h3>Graphics Card: </h3>
<?php
echo $seventhchoice;
?>
</div>
<div id="TotalCost">
<?php
echo nl2br (" \r\n");
$overall_price = $total_price1 + $total_price2 + $total_price3 + $total_price4 + $total_price5 + $total_price6 + $total_price7;
echo "Total Cost: " .$overall_price;
?>
</div>
</div>
</div>
<body>
<html>
這並不是說這裏是最大的問題的安全性,它只是不維護。老實說,這段代碼是一場噩夢 – 2013-03-13 02:07:11
你是否認爲POST可能是空的,或者沒有任何變量的選擇? 做一個var_dump($ _ POST)並檢查裏面有什麼。 – sikander 2013-03-13 02:08:50
你應該學會使用數組。 – didierc 2013-03-13 02:11:41