ShadowIce Posted January 16, 2010 Share Posted January 16, 2010 I am in need of some URGENT help! Why can't I get the session to display the correct price on vieworder.php?! >< Orderform.php: <?php session_start(); ?><?php /*This code is for use on www.imageposeidon.com ONLY! Using this code without written permission from imageposeidon.com is a violation of the GNU Public License (GPL) And will be dealt with to the fullest extent of the law */ ?><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Image Poseidon</title> </head> <body onsubmit="return validate_required(this)" style="font-family: Arial"> <script src="cstate_0001.js"></script> <?php require('header.php'); ?> <Script Language="JavaScript" type="JavaScript"> function validate_required(field) { var alerttxt = "One or more fields are empty.\\nPlease fill them out before submitting"; with (field) { if (value==null||value=="") { alert(alerttxt); return false; }else{ return true; } } } </Script> <FORM onsubmit="return validate_required(this)" ACTION="page2.php" method=post> <center> <table border="0"> <tr> <td><label for="fname_0001">First Name: </label></td> <td><input type="text" name="f_name0001" maxlength="30" id="f_name0001" size="30" /></td> </tr> <tr> <td><label for="lname_0001">Last Name: </label></td> <td><input type="text" name="l_name0001" maxlength="30" id="l_name0001" size="30" /></td> </tr> <tr> <td><label for="a_d0001">Shipping Address: </label></td> <td><input type="text" name="ad_0001" maxlength="128" id="ad_0001" size="30" /></td> </tr> <tr> <td>Country: </td> <td><select id='countrySelect' name='co_0001' onchange='populateState()' style="width: 209px;"></select></td> </tr> <tr> <td><label for="c0001">City: </label></td> <td><input type="text" name="c_0001" maxlength="30" id="c_0001" size="30" /></td> </tr> <br><br> <tr> <td>State: </td> <td><select name='sp_0001' id='stateSelect' name='state' style="width: 209px;"></select></td> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> <td width=150>Item: <br> </td> <td width=15>Quantity: <br> </td> </tr> <tr> <td>CD</td> <td><input type="text" name="qtycd_0001" value = "1" size="30" maxlength="7"></td> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> </tr> <tr> <td>Please enter a discount code if you have one: </td> <td><input type="text" name="sd_0001" value="000-000-00000" size="30" maxlength="64"></td> </tr> <tr> <td><input onsubmit="return validate_required(this)" type="submit" value="Go To Next Page"></td> </tr> <script type="text/javascript">initCountry('US');</script> </table> </center> </form> </body> </html> page2.php (displays your total amount of products u bought.. etc..): <?php session_start(); require('sessionvars.php'); ?><?php /*This code is for use on www.imageposeidon.com ONLY! Using this code without written permission from imageposeidon.com is a violation of the GNU Public License (GPL) And will be dealt with to the fullest extent of the law */?><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('sessvars.php'); ?> <center> <h2>This is your order so far: </h2> </center> <FORM name="f0001" id="f0001" ACTION="processorder.php?fname=<?php echo $fname;?>" method=post> <center> <?php echo "Name: <b><u>".$fname." ".$lname."</u></b><br>\n" ."Address: <b><u>".$address."</u></b><br>\n" ."Country: <b><u>".$country."</u></b><br>\n" ."City: <b><u>".$city."</u></b><br>\n" ."State/Province: <b><u>".$stateprov."</u></b><br>\n" ."Amount of CD(s) you want to purchase: <b><u>".$quantity."</u></b><br>\n"; if($hasdiscount == true){echo "Your coupon code: <b><u>".$myCoupon."</u></b><br><br>\n";} echo "<img src=\"gradient_grey3596386127_footer-iaza.png\"></img><br>\n"; if($hasdiscount == true){ echo "<br>Original Total: <br><br>\n" ."<b>".$print_pur_po_total."-"."10%"."</b>"."<br>\n" ."<br>Your total: <br><br>\n" ."<b>".$print_pur_po_total2."</b><br>\n"; }else if($hasdiscount == false){ echo "<br>Your Total: <br><br>\n" ."<b>".$print_pur_po_total."</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> variables.php: <?php $number = $Total; $number2 = $DiscountTotal; $pur_item_total = $number; $pur_po_total = ($pur_po_total + $pur_item_total); $print_pur_po_total = wims_currency($pur_po_total); $pur_item_total2 = $number2; $pur_po_total2 = ($pur_po_total2 + $pur_item_total2); $print_pur_po_total2 = wims_currency2($pur_po_total2); ?> 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['hascouponcode'] = $myCoupon; $_SESSION['hasadiscount'] = $hasdiscount; $_SESSION['istotal'] = $print_pur_po_total; $_SESSION['isdiscounttotal'] = $print_pur_po_total2; ?> sessvars.php (different from sessionvars.php): <?php $fname = $_SESSION['f_name0001']; $lname = $_SESSION['l_name0001']; $address = $_SESSION['ad_0001']; $country = $_SESSION['co_0001']; $city = $_SESSION['c_0001']; $stateprov = $_SESSION['sp_0001']; $quantity = $_SESSION['qtycd_0001']; $istotal = $_SESSION['istotal']; $isdiscounttotal = $_SESSION['isdiscounttotal']; //$hascouponcode //$hasthediscount // if found return the position in the array as $key if(($key = array_search($myCoupon, $coupons)) !== false) { $hasdiscount = true; } else if(($key = array_search($myCoupon, $coupons)) == false) { $hasdiscount = false; } $couponcode = $myCoupon; ?> taxheader.php: <?php $itemprice = 12; $taxrate = 7; $shipping = 1.75; $discountrate = .90; $qtycd = $_POST['qtycd_0001']; $sdiscount = $_POST['sd_0001']; $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']; $sdiscount = $myCoupon; // 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('sessvars.php'); ?> <center> <h2>Your Receipt: </h2> <?php echo "fname: ".$fname."<br>\n" ."lname: ".$lname."<br>\n" ."address: ".$address."<br>\n" ."country: ".$country."<br>\n" ."city: ".$city."<br>\n" ."stateprov: ".$stateprov."<br>\n" ."quantity: ".$quantity."<br>\n" ."total: ".$istotal."<br>\n" ."discount total: ".$isdiscounttotal."<br>\n" ."coupon code: ".$hascouponcode."<br>\n" ."has discount: ".$hasthediscount."<br>\n"; echo "Name: <b><u>".$fname." ".$lname."</u></b><br>\n" ."Address: <b><u>".$address."</u></b><br>\n" ."Country: <b><u>".$country."</u></b><br>\n" ."City: <b><u>".$city."</u></b><br>\n" ."State/Province: <b><u>".$stateprov."</u></b><br>\n" ."Amount of CD(s) you want to purchase: <b><u>".$quantity."</u></b><br>\n"; if($hasdiscount == true){echo "Your coupon code: <b><u>".$couponcode."</u></b><br><br>\n";} if($hasdiscount == true){ echo "<br>Original Total: <br><br>\n" ."<b>".$total."-"."10%"."</b>"."<br>\n" ."<br>Your total: <br><br>\n" ."<b>".$discounttotal."</b><br>\n"; }else if($hasdiscount == false){ echo "<br>Your Total: <br><br>\n" ."<b>".$total."</b><br>\n"; } echo "<br>\n"; ?> </center> <?php function test() { $foo = "local variable"; echo '$foo in global scope: ' . $GLOBALS["foo"] . "<br>\r\n"; echo '$foo in current scope: ' . $foo . "<br>\r\n"; } $foo = "Example content"; test(); ?> <form name="test" id="test" action="./vartest.php" method="POST"> <input type="submit" value="Submit"> </form> </body> </html> In vieworder.php, I cant get $hasdiscount to work, and I can't get $total, $discounttotal, and $myCoupon to display.... Thanks! ShadowIce~ Link to comment https://forums.phpfreaks.com/topic/188700-urgent-sessions-not-displaying-correct-price-coupon-code-on-order-receipt-page/ Share on other sites More sharing options...
jskywalker Posted January 16, 2010 Share Posted January 16, 2010 water is URGENT to people in HAITI, this post is nog URGENT... Link to comment https://forums.phpfreaks.com/topic/188700-urgent-sessions-not-displaying-correct-price-coupon-code-on-order-receipt-page/#findComment-996156 Share on other sites More sharing options...
ShadowIce Posted January 16, 2010 Author Share Posted January 16, 2010 Yes I know, but please don't ruin my thread if alls your going to do is complain about it. I don't do that to you. But I might if you keep this up.. Link to comment https://forums.phpfreaks.com/topic/188700-urgent-sessions-not-displaying-correct-price-coupon-code-on-order-receipt-page/#findComment-996158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.