Adding scripts

From: Date: Sat, 28 Jul 2001 04:41:07 +0000
Subject: Adding scripts
Groups: php.general 
Request: Send a blank email to php-general+get-60028@lists.php.net to get a copy of this message
Hi, I'm creating a very simple script (or so I thought) in which a user can select items from a form, the script will take the number values of those items and do two things: display the names of the items selected, and add the items together and give the user a total price including taxes. In my form, I use the following syntax: <input type="checkbox" name="hit_955" value="14.72"> The form is then sent using the POST method. I then retrieve the values using the following syntax: $hit_955 = $HTTP_POST_VARS["hit_955"]; All together there are 14 items a user can choose - for testing purposes, I chose all items. The script would only display and add the first, second, and tenth items. All others are ignored. Here is the script - its broken into three parts - the first part is collecting the information - the second part is doing the actual math - and the third part displays the item names that the user chose. Does anyone see anything wrong with this script, or have a possible reason why its only choosing 3 out of 14 items to work with? PART ONE: <? $SubTotal = 0; $FormattedSubTotal = 0; $Total = 0; $FormattedTotal = 0; $PST = 1.08; $GST = 1.07; $CalcPST = 0; $CalcGST = 0; $FormattedPST = 0; $FormattedGST = 0; $nokia252c = 0; $battery = 0; $hit_955 = 0; $hit_965 = 0; $nok_cbl_7 = 0; $nok_lch_6rpd = 0; $nok_cgh10 = 0; $nok_lch9 = 0; $belt_252 = 0; $nokia_0261670 = 0; $s_nok_0261669 = 0; $nok_mbc_3k = 0; $nok_cark_89 = 0; $nok_cark_90 = 0; $nokia252c = $HTTP_POST_VARS["nokia252c"]; $battery = $HTTP_POST_VARS["battery"]; $hit_955 = $HTTP_POST_VARS["hit_955"]; $hit_965 = $HTTP_POST_VARS["hit_965"]; $nok_cbl_7 = $HTTP_POST_VARS["nok_cbl_7"]; $nok_lch_6rpd = $HTTP_POST_VARS["nok_lch_6rpd"]; $nok_cgh10 = $HTTP_POST_VARS["nok_cgh10"]; $nok_lch9 = $HTTP_POST_VARS["nok_lch9"]; $belt_252 = $HTTP_POST_VARS["belt_252"]; $nokia_0261670 = $HTTP_POST_VARS["nokia_0261670"]; $s_nok_0261669 = $HTTP_POST_VARS["s_nok_0261669"]; $nok_mbc_3k = $HTTP_POST_VARS["nok_mbc_3k"]; $nok_cark_89 = $HTTP_POST_VARS["nok_cark_89"]; $nok_cark_90 = $HTTP_POST_VARS["nok_cark_90"]; ?> PART TWO: <? $SubTotal = $nokia252c + $battery + $hit_955 + $hit_965 + $nok_cbl_7 + $nok_lch_6rpd + $nok_cgh10 + $nok_lch9 + $belt_252 + $nokia_0261670 + $s_nok_0261669 + $nok_mbc_3k + $nok_cark_89 + $nok_cark_90; $CalcPST = ($SubTotal * $PST) - $SubTotal; $CalcGST = ($SubTotal * $GST) - $SubTotal; $Total = $SubTotal + $CalcPST + $CalcGST; $FormattedSubTotal = number_format($SubTotal, 2); $FormattedPST = number_format($CalcPST, 2); $FormattedGST = number_format($CalcGST, 2); $FormattedTotal = number_format($Total, 2); ?> PART THREE: <? if ($nokia252c > 0) { echo "Nokia 252c"; } else { echo ""; } ?> Thanks -Tim

« previous php.general (#60028) next »