ShadowIce Posted January 17, 2010 Share Posted January 17, 2010 On second thought, no. it's NOT fixed.. It's now displaying $_SESSION['istotal'] & $_SESSION['isdiscounttotal'] as $0.00.... PLEASE HELP! >< page2.php: <?php session_start(); require('sessionvars.php'); ?><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Image Poseidon</title> </head> <body style="font-family: Arial"> <script src="view_printable.js"></script> <script src="mainscripts.js"></script> <center> <a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br> </center> <?php require('header.php'); require('taxheader.php'); require('sessionvars.php'); ?> <center> <h2>This is your order so far: </h2> </center> <FORM name="f0001" id="f0001" ACTION="processorder.php" method=post> <center> <?php echo "Name: <b><u>".$_SESSION['f_name0001']." ".$_SESSION['l_name0001']."</u></b><br>\n" ."Address: <b><u>".$_SESSION['ad_0001']."</u></b><br>\n" ."Country: <b><u>".$_SESSION['co_0001']."</u></b><br>\n" ."City: <b><u>".$_SESSION['c_0001']."</u></b><br>\n" ."State/Province: <b><u>".$_SESSION['sp_0001']."</u></b><br>\n" ."Amount of CD(s) you want to purchase: <b><u>".$_SESSION['qtycd_0001']."</u></b><br>\n"; if($_SESSION['hasadiscount'] == true){echo "Your coupon code: <b><u>".$_SESSION['customercouponcode']."</u></b><br><br>\n";} echo "<img src=\"gradient_grey3596386127_footer-iaza.png\"></img><br>\n"; if($_SESSION['hasadiscount'] == true){ echo "<br>Original Total: <br><br>\n" ."<b>".$_SESSION['istotal']."-"."10%"."</b>"."<br>\n" ."<br>Your total: <br><br>\n" ."<b>".$_SESSION['isdiscounttotal']."</b><br>\n"; }else if($_SESSION['hasadiscount'] == false){ echo "<br>Your Total: <br><br>\n" ."<b>".$_SESSION['istotal']."</b><br>\n"; } echo "<br>\n"; echo "<img src=\"gradient_grey3596386127-iaza.png\"></img>\n"; ?> <br> <a href="#" onclick="javascript:view_printable();">Click For Printable Page</a><br><br> <input name="subt1" id="subt1" type="submit" value="Submit" onclick="FormControl(1);"> </center> </form> </body> </html> sessionvars.php: <?php $_SESSION['f_name0001'] = $_POST['f_name0001']; $_SESSION['l_name0001'] = $_POST['l_name0001']; $_SESSION['ad_0001'] = $_POST['ad_0001']; $_SESSION['co_0001'] = $_POST['co_0001']; $_SESSION['c_0001'] = $_POST['c_0001']; $_SESSION['sp_0001'] = $_POST['sp_0001']; $_SESSION['qtycd_0001'] = $_POST['qtycd_0001']; $_SESSION['customercouponcode'] = $myCoupon; $_SESSION['hasadiscount'] = $hasdiscount; $_SESSION['istotal'] = $print_pur_po_total; $_SESSION['isdiscounttotal'] = $print_pur_po_total2; echo "Firstname: ".$_SESSION['f_name0001']."<br>\n" ."Lastname: ".$_SESSION['l_name0001']."<br>\n" ."Address: ".$_SESSION['ad_0001']."<br>\n" ."Country: ".$_SESSION['co_0001']."<br>\n" ."City: ".$_SESSION['c_0001']."<br>\n" ."State / Province: ".$_SESSION['sp_0001']."<br>\n" ."Quantity: ".$_SESSION['qtycd_0001']."<br>\n" ."Coupon code: ".$_SESSION['customercouponcode']."<br>\n" ."Has discount: ".$_SESSION['hasadiscount']."<br>\n" ."is total: ".$_SESSION['istotal']."<br>\n" ."is discount total: ".$_SESSION['isdiscounttotal']."<br>\n" ."Total: ".$print_pur_po_total."<br>\n" ."Discount Total: ".$print_pur_po_total2."<br>\n"; ?> taxheader.php: <?php $itemprice = 12; $taxrate = 7; $shipping = 1.75; $discountrate = .90; $Subtotal = $itemprice; $Tax = round( ($itemprice * $taxrate / 100 ), 2); $Total = (($Tax + $Subtotal)*$qtycd)+($shipping*$qtycd); $DiscountTotal = $Total*$discountrate; //round($Total*($discountrate), 2); $coupons = file('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', FILE_SKIP_EMPTY_LINES); $coupons = array_map('trim', $coupons); $myCoupon = $_POST['sd_0001']; $hasdiscount = false; // if found return the position in the array as $key if(($key = array_search($myCoupon, $coupons)) !== false) { $hasdiscount = true; // delete the coupon from the array using $key unset($coupons[$key]); file_put_contents('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', implode("\r\n", $coupons)); } else if(($key = array_search($myCoupon, $coupons)) == false) { $hasdiscount = false; } $number = $Total; $pur_item_total = $number; $pur_po_total = ($pur_po_total + $pur_item_total); $print_pur_po_total = wims_currency($pur_po_total); $number2 = $DiscountTotal; $pur_item_total2 = $number2; $pur_po_total2 = ($pur_po_total2 + $pur_item_total2); $print_pur_po_total2 = wims_currency2($pur_po_total2); function wims_currency($number) { if ($number < 0) { $print_number = "($" . str_replace('-', '', number_format ($number, 2, ".", ",")) . ")"; } else { $print_number = "$" . number_format ($number, 2, ".", ",") ; } return $print_number; } function wims_currency2($number2) { if ($number2 < 0) { $print_number2 = "($" . str_replace('-', '', number_format ($number2, 2, ".", ",")) . ")"; } else { $print_number2 = "$" . number_format ($number2, 2, ".", ",") ; } return $print_number2; } ?> vieworder.php: <?php session_start(); ?><html> <head><title>Image Poseidon - Order Form</title></head> <body> <?php require('taxheader.php'); require('variables.php'); require('sessionvars.php'); ?> <center> <h2>Your Receipt: </h2> <hr/> <?php echo "Name: <b><u>".$_SESSION['f_name0001']." ".$_SESSION['l_name0001']."</u></b><br>\n" ."Address: <b><u>".$_SESSION['ad_0001']."</u></b><br>\n" ."Country: <b><u>".$_SESSION['co_0001']."</u></b><br>\n" ."City: <b><u>".$_SESSION['c_0001']."</u></b><br>\n" ."State/Province: <b><u>".$_SESSION['sp_0001']."</u></b><br>\n" ."Amount of CD(s) you want to purchase: <b><u>".$_SESSION['qtycd_0001']."</u></b><br>\n"; if($_SESSION['hasadiscount'] == true){echo "Your coupon code: <b><u>".$_SESSION['customercouponcode']."</u></b><br><br>\n";} if($_SESSION['hasadiscount'] == true){ echo "<hr/>\n"; echo "<br>Original Total: <br><br>\n" ."<b>".$_SESSION['istotal']."-"."10%"."</b>"."<br>\n" ."<br>Your total: <br><br>\n" ."<b>".$_SESSION['isdiscounttotal']."</b><br>\n"; }else if($_SESSION['hasadiscount'] == false){ echo "<hr/>\n"; echo "<br>Your Total: <br><br>\n" ."<b>".$_SESSION['istotal']."</b><br>\n"; } echo "<br>\n"; ?> </center> </body> </html> Thanks! ShadowIce~ Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/ Share on other sites More sharing options...
waynew Posted January 17, 2010 Share Posted January 17, 2010 Where are you getting $print_pur_po_total from? Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996778 Share on other sites More sharing options...
ShadowIce Posted January 17, 2010 Author Share Posted January 17, 2010 from taxheader.php: and im getting $Total and $DiscountTotal from taxheader.php as well: <?php $itemprice = 12; $taxrate = 7; $shipping = 1.75; $discountrate = .90; $Subtotal = $itemprice; $Tax = round( ($itemprice * $taxrate / 100 ), 2); $Total = (($Tax + $Subtotal)*$qtycd)+($shipping*$qtycd); $DiscountTotal = $Total*$discountrate; //round($Total*($discountrate), 2); $coupons = file('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', FILE_SKIP_EMPTY_LINES); $coupons = array_map('trim', $coupons); $myCoupon = $_POST['sd_0001']; $hasdiscount = false; $number = $Total; $pur_item_total = $number; $pur_po_total = ($pur_po_total + $pur_item_total); $print_pur_po_total = wims_currency($pur_po_total); $number2 = $DiscountTotal; $pur_item_total2 = $number2; $pur_po_total2 = ($pur_po_total2 + $pur_item_total2); $print_pur_po_total2 = wims_currency2($pur_po_total2); function wims_currency($number) { if ($number < 0) { $print_number = "($" . str_replace('-', '', number_format ($number, 2, ".", ",")) . ")"; } else { $print_number = "$" . number_format ($number, 2, ".", ",") ; } return $print_number; } function wims_currency2($number2) { if ($number2 < 0) { $print_number2 = "($" . str_replace('-', '', number_format ($number2, 2, ".", ",")) . ")"; } else { $print_number2 = "$" . number_format ($number2, 2, ".", ",") ; } return $print_number2; } ?> Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996779 Share on other sites More sharing options...
waynew Posted January 17, 2010 Share Posted January 17, 2010 You're going track each variable back to its original source. If you do that, I promise you'll find the problem. You're very liberal with how you copy your variables. Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996781 Share on other sites More sharing options...
ShadowIce Posted January 17, 2010 Author Share Posted January 17, 2010 I tried that. It didn't work. It's showing $0.00 still Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996782 Share on other sites More sharing options...
ShadowIce Posted January 17, 2010 Author Share Posted January 17, 2010 Can anyone else help me please? Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996814 Share on other sites More sharing options...
ShadowIce Posted January 17, 2010 Author Share Posted January 17, 2010 Ok. I've narrowed it down. the problem is in this file: taxorder.php: <?php $itemprice = 12; $taxrate = 7; $shipping = 1.75; $discountrate = .90; $Subtotal = $itemprice; $Tax = round( ($itemprice * $taxrate / 100 ), 2); $Total = (($Tax + $Subtotal)*$qtycd)+($shipping*$qtycd); $DiscountTotal = $Total*$discountrate; //round($Total*($discountrate), 2); $coupons = file('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', FILE_SKIP_EMPTY_LINES); $coupons = array_map('trim', $coupons); $myCoupon = $_POST['sd_0001']; $hasdiscount = false; // if found return the position in the array as $key if(($key = array_search($myCoupon, $coupons)) !== false) { $hasdiscount = true; // delete the coupon from the array using $key unset($coupons[$key]); file_put_contents('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.txt', implode("\r\n", $coupons)); } else if(($key = array_search($myCoupon, $coupons)) == false) { $hasdiscount = false; } $number = $Total; $pur_item_total = $number; $pur_po_total = ($pur_po_total + $pur_item_total); $print_pur_po_total = wims_currency($pur_po_total); $number2 = $DiscountTotal; $pur_item_total2 = $number2; $pur_po_total2 = ($pur_po_total2 + $pur_item_total2); $print_pur_po_total2 = wims_currency2($pur_po_total2); function wims_currency($number) { if ($number < 0) { $print_number = "($" . str_replace('-', '', number_format ($number, 2, ".", ",")) . ")"; } else { $print_number = "$" . number_format ($number, 2, ".", ",") ; } return $print_number; } function wims_currency2($number2) { if ($number2 < 0) { $print_number2 = "($" . str_replace('-', '', number_format ($number2, 2, ".", ",")) . ")"; } else { $print_number2 = "$" . number_format ($number2, 2, ".", ",") ; } return $print_number2; } echo "Has discount: ".$hasdiscount."<br>\n" ."$"."print_pur_po_total=".$print_pur_po_total."<br>\n" ."$"."print_pur_po_total2=".$print_pur_po_total2."<br>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996829 Share on other sites More sharing options...
ShadowIce Posted January 17, 2010 Author Share Posted January 17, 2010 On a final note: Case: Closed! Problem has been solved! =D I found the problem! =D Link to comment https://forums.phpfreaks.com/topic/188795-please-help-prices-now-not-displaying-correctly-on-php-page/#findComment-996836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.