1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Putting a variable in the value field of a form

Discussion in 'PHP' started by rob6188, Aug 16, 2007.

  1. #1
    I'm just getting started in php and using forms to pass the variables via post and/or session.

    Here is what I want to do. I want 900 to pass onto the next page when I submit.

    
    $subtotal = 900;
     
    <input type="hiddend" name="total" value=$subtotal />
     
    <input type="submit" name="Submit" value="Pay" />
    
    Code (markup):

    However, the above code just passes a 0.

    Is there a way to pass $subtotal ?
    Thanks.
     
    rob6188, Aug 16, 2007 IP
  2. deBassMan

    deBassMan Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use a SESSION variable
     
    deBassMan, Aug 16, 2007 IP
  3. rob6188

    rob6188 Peon

    Messages:
    219
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I guess I should elaborate a little bit more.

    I need to pass the $900 to the merhant's site. The example they gave me was

    
    ...action=[URL]https://merchantsite.com/process.asp[/URL] />
     
    <input type="text" name="total" value="900">
    
    Code (markup):
    However, I have a script that calculates the subtotal for the customer, so all they have is click the "pay" button.

    Thanks for the quick repsonse though.

    -Rob
     
    rob6188, Aug 16, 2007 IP
  4. jazz7620

    jazz7620 Banned

    Messages:
    357
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you should say

    <input type="hiddend" name="total" value="<? echo $subtotal;?>" />
     
    jazz7620, Aug 16, 2007 IP
    rob6188 likes this.
  5. rob6188

    rob6188 Peon

    Messages:
    219
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5

    :):D:):D

    Thank you! That Worked!

    Rep added.
     
    rob6188, Aug 16, 2007 IP
  6. supperman

    supperman Peon

    Messages:
    22
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    that's cool,and that's the easiest way

    of course,you can type

    <input type="hiddend" name="total" value="<?=$subtotal;?>" />

    for short,but it is not recommened now.
     
    supperman, Aug 17, 2007 IP
    rob6188 likes this.
  7. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This should work 100%,

    <input type="hidden" name="total" value="<?php echo $subtotal;?>" />
    Code (markup):
     
    tamilsoft, Aug 17, 2007 IP
    rob6188 likes this.