How to make this script functional

Discussion in 'PHP' started by jainritesh, May 10, 2008.

  1. #1
    Dear DP members,
    I am trying to create promo code for Paypal button, i am not able to check wheter the promo code enter is correct or wrong, Please guide where i am wrong in this script

    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    include("buy_config.php");
    ?>
    
    /// Here the user will enter promotional code to get discount in Product 
    
    <FORM action="<? echo $path ?>#promo" method="post">
    <br><font size = "<? echo $Fsize ?>"> <? echo $Ptxt ?> $<? echo $amount ?></font>
    <br>
    <br><font size = "2"> <? echo $Promo_txt ?></font>
    <br />
    <input type="text" name="code" size="8" />
    <INPUT type="submit" value="Recalculate">
    </form>
    
    //// On pressing Recalculate The script will come here to check if the promo //// code entered is wrong it will display wrong code, else it will display ////correct code and will update the amount value in Paypal.
    
    <A name=promo></A>
    <table CELLPADDING=12 CELLSPACING=12><tr><td>
    <?
    $code = $_REQUEST['code'];
    if($code==$Promo_code)
    {
    echo ("<center><br><br><br><br><br><br><b>Correct Code</b><br><br><br><br><br><br></center>");
    }
    else {
    echo ("<center><br><br><br><br><br><br><b>Wrong Code</b><br><br><br><br><br><br></center>");
    }
    ?>
    
    PHP:

    Thanxs in advance,
    Best Regards,
    Ritesh Jain
     
    jainritesh, May 10, 2008 IP
  2. jainritesh

    jainritesh Well-Known Member

    Messages:
    551
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    Please Help, I am still trying to solve the problem in this script
    Best Regards,
    Ritesh
     
    jainritesh, May 25, 2008 IP
  3. Agent_Smith

    Agent_Smith Well-Known Member

    Messages:
    890
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    145
    #3
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    include("buy_config.php");
    ?>
    
    /// Here the user will enter promotional code to get discount in Product 
    
    <FORM action="<? echo $path ?>#promo" method="post">
    <br><font size = "<? echo $Fsize ?>"> <? echo $Ptxt ?> $<? echo $amount ?></font>
    <br>
    <br><font size = "2"> <? echo $Promo_txt ?></font>
    <br />
    <input type="text" name="code" size="8" />
    <INPUT type="submit" value="Recalculate">
    </form>
    
    //// On pressing Recalculate The script will come here to check if the promo //// code entered is wrong it will display wrong code, else it will display ////correct code and will update the amount value in Paypal.
    
    <A name=promo></A>
    <table CELLPADDING=12 CELLSPACING=12><tr><td>
    <?
    $code = $_POST['code'];
    if($code==$Promo_code)
    {
    echo ("<center><br><br><br><br><br><br><b>Correct Code</b><br><br><br><br><br><br></center>");
    }
    else {
    echo ("<center><br><br><br><br><br><br><b>Wrong Code</b><br><br><br><br><br><br></center>");
    }
    ?>
    PHP:
     
    Agent_Smith, May 27, 2008 IP
  4. nastynappy

    nastynappy Banned

    Messages:
    499
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Find :

    $code = $_REQUEST['code'];

    Replace with :

    $code = $_POST['code'];

    since you are using a form to submit data, you need to use $_POST, not $_REQUEST :)

    Hope it helps you :)
     
    nastynappy, May 27, 2008 IP