Need Help w/ Small Paypal Script

Discussion in 'PHP' started by JeremyM, Sep 17, 2008.

  1. #1
    So I have a little knowledge of PHP and by a little I mean almost none.

    I'm trying to create a script though that will let someone select their options and then it will display them the price and once they click subscribe or submit it will send it off.

    I pretty much just started and am already having trouble. Basically what I am trying right now is to have the user select what plan they want, and based on that option, input a hidden price and display that hidden price. For some reason it won't display the price. Why? Not sure thats what I would like to know how to do.

        	<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
            	<select name="item_name">
                	<option value="HxC | Basic Admin (1 Server)">Basic Admin (1 Server)</option>
                    <option value="HxC | Basic Admin (All Servers)">Basic Admin (All Servers)</option>
                    <option value="HxC | Full Admin (1 Server)">Full Admin (1 Server)</option>
                    <option value="HxC | Full Admin (All Server)">Full Admin (All Servers)</option>
                </select>
                <input type="hidden" name="a3" value="
                					<?php
                                    	if ($item_name == "HxC | Basic Admin (1 Server)") {
    										echo "2.50";
    									} elseif ($item_name == "HxC | Basic Admin (All Servers)") {
    										echo "5.00";
    									} elseif ($item_name == "HxC | Full Admin (1 Server)") {
    										echo "7.50";
    									} elseif ($item_name == "HxC | Full Admin (All Server)") {
    										echo "10.00";
    									} else { 
    										echo "0.00";
    									}
    								?>
    									">
                                        <br /><br />
                                        	Your total is <?= $a3 ?>
                <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_subscribe_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
                <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
                <input type="hidden" name="cmd" value="_xclick-subscriptions">
                <input type="hidden" name="business" value="jjmalais@gmail.com">
                <input type="hidden" name="item_name" value="HxC | Basic Admin (1 Server)">
                <input type="hidden" name="item_number" value="unsure">
                <input type="hidden" name="no_shipping" value="1">
                <input type="hidden" name="no_note" value="1">
                <input type="hidden" name="currency_code" value="USD">
                <input type="hidden" name="lc" value="US">
                <input type="hidden" name="bn" value="PP-SubscriptionsBF">
                <input type="hidden" name="p3" value="1">
                <input type="hidden" name="t3" value="M">
                <input type="hidden" name="src" value="1">
                <input type="hidden" name="sra" value="1">
    </form>
    Code (markup):

    Please help me out!!! And thanks :)
     
    JeremyM, Sep 17, 2008 IP
  2. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #2
    you are treading PHP as if it was ajax/javascript.

    php can only get active, when something is sent to the server and the server gives response.

    when this page is loaded in a browser, php will not get active, just by toggling the Select-box.


    things like "calculate-price-upon-userchange-in-one-of-the-forms-elements" are done via ajax/javascript.
     
    happpy, Sep 17, 2008 IP
  3. JeremyM

    JeremyM Peon

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Doh!

    Well thanks, haha.
     
    JeremyM, Sep 17, 2008 IP