Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Apr 2009
    Posts
    264
    Thanks
    24
    Thanked 1 Time in 1 Post

    URGENT! Sessions not displaying correct price / coupon code on order receipt page! ><

    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 Code:
    <?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>
    &nbsp;</td>
    <td width=15>Quantity: <br>
    &nbsp;</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 Code:
    <?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 Code:
    <?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 Code:
    <?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 Code:
    <?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 Code:
    <?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('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXYldoeVZrZDRWMD VzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.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('Vm1wS01HRXhVWGxWYmxKV1lrZG9VRlpyVmt0WGJGSllZM3BHVG1KSFVubFhhMXByWWtkR05sSnJXbFpXY ldoeVZrZDRWMDVzV2xsYVIwWlhWakpvVkZaVldrWlBWa0pTVUZRd1BRPT0=.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 ($number2"."",")) . ")";
    } else {
    $print_number "$" number_format ($number2"."",") ;
    }
    return 
    $print_number;
    }

    function 
    wims_currency2($number2) {
    if (
    $number2 0) {
    $print_number2 "($" str_replace('-'''number_format ($number22"."",")) . ")";
    } else {
    $print_number2 "$" number_format ($number22"."",") ;
    }
    return 
    $print_number2;
    }

    ?>
    vieworder.php:

    PHP Code:
    <?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~
    Last edited by Fou-Lu; 01-19-2010 at 02:28 AM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    There is no need to have two if's for the same thing.

    PHP Code:
    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";


    Just to let you know, it'd clean up your code a little.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    Regular Coder
    Join Date
    Apr 2009
    Posts
    264
    Thanks
    24
    Thanked 1 Time in 1 Post
    Thanks, but that doesn't solve this problem..

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    I wasn't solving the problem, was just helping you clean the coding.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #5
    New Coder
    Join Date
    Dec 2009
    Posts
    84
    Thanks
    6
    Thanked 3 Times in 3 Posts
    You not just only need to solve your present code but you most need how to secure (prevent from attacker) your business membership... by looking to your present code it's seem easy for someone to delete your all membership... and also you coupon code, from the beginning when you request some helps i know you will face this problem... you can believe it or not

    You need someone to help you out...
    Best Regards,

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    You may be breaking it on page2. At the top, you include sessionvars.php which has these lines at the end:
    PHP Code:
    $_SESSION['hascouponcode'] = $myCoupon;
    $_SESSION['hasadiscount'] = $hasdiscount;
    $_SESSION['istotal'] = $print_pur_po_total;
    $_SESSION['isdiscounttotal'] = $print_pur_po_total2
    Those four variable on the right are undefined at that point, which means that you're assigning empty values to those session variables. I also notice that shortly after that your re-use some of them in sessvars.php and that's going to perpetuate the problem. Take a look at your session on that page with a print_r at the bottom.

    A simple debug step is to echo/print/dump variables throughout a page or multiple pages to make sure you're actually getting what you think you should be getting. If I'm right with the assessment above, you would have noticed this with a simple echo.

    Also, you should take the advice already offered. That code needs a bit of help.

    Finally, are you imageposeidon.com? Allow me, without knowing if you're responsible, to call BS on that "license" statement at the top of those files. That's not how the GPL works. If you have put that nonsense in your files, you need to remove it before you take a beatdown for mis-using the GPL. If you're just copying-and-pasting someone else's work, I suggest learning a bit about the GPL first and then passing a friendly link back to the originator.
    Are you a Help Vampire?

  • #7
    Regular Coder
    Join Date
    Apr 2009
    Posts
    264
    Thanks
    24
    Thanked 1 Time in 1 Post
    Um. EXCUSE me? I DID write that code. Why do u think its not very organized? oO
    Also, go ahead. look on the internet for it. You WON'T find it.

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Then you need to learn to use the GPL before posting that nonsensical "license" statement at the top. If you don't want anyone to use your code, GPL is not the license you want.
    Are you a Help Vampire?

  • #9
    Regular Coder
    Join Date
    Apr 2009
    Posts
    264
    Thanks
    24
    Thanked 1 Time in 1 Post
    Then what license DO I want? Cuz no one TAUGHT me where to find it

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    It's not a world of handouts, for the most part. Some things (most?) need to be learned without being spoon-fed from a teacher.

    If you're a US citizen, I suggest looking at the government's copyright site and reading about the basics. Copyright ostensibly protects the work from use without permission. That being said, it doesn't work well for digital products (ever downloaded an MP3 without paying a fee?). Still, it's protection at least in name. Technically, you hold the copyright to anything you create anyway, but a copyright notice asserts the fact textually.

    You don't need to register with an organization or government to hold copyright on a work. For more info, see the Copyright Basics pdf on the gov site and note specifically the section titled "How to Secure a Copyright".
    Are you a Help Vampire?

  • #11
    Regular Coder
    Join Date
    Apr 2009
    Posts
    264
    Thanks
    24
    Thanked 1 Time in 1 Post
    Bah. what am I saying? I already have a copyright on my product. I mailed it to myself. I'm just gonna say problem solved...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •