By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

Passing a value from php to "form"

P: 1
I need to pass a variable from a php function to a form. Does anyone have an example of code that would do this?

Below is the code. I need to pass the "return value" from the php function mem_cost to the "amount" listed in the "form"

Expand|Select|Wrap|Line Numbers
  1.  <?php 
  2. function mem_cost()
  3. {
  4. $w_month = strftime("%m");
  5.  
  6. if (($w_month >= "01") && ($w_month <= "06"))
  7.         {
  8.         $amt = "30.00";
  9.         return $amt;
  10.         }
  11. else
  12.         {
  13.         $amt = "60.00";
  14.         return $amt;
  15.         }
  16. }
  17. ?>
  18.  
  19. <form target="bridge-data" action="https://www.nowhere.com/display.html" method="post">
  20. <input type="image" src="http://www.nowhere.com/image/btn/btn01.gif" border="0" name="submit" alt="Press here for to purchase item">
  21. <img alt="" border="0" src="http://www.nowhere.com/image/pixel.gif" width="1" height="1">
  22. <input type="hidden" name="add" value="1">
  23. <input type="hidden" name="cmd" value="_cart">
  24. <input type="hidden" name="business" value="xxx1@nowhere.com">
  25. <input type="hidden" name="item_name" value="Membership Dues">
  26. <input type="hidden" name="item_number" value="4600">
  27. <input type="hidden" name="amount" value="needs to be return value from fuction">
  28. <input type="hidden" name="buyer_credit_promo_code" value="">
  29. <input type="hidden" name="buyer_credit_product_category" value="">
  30. <input type="hidden" name="buyer_credit_shipping_method" value="">
  31. <input type="hidden" name="buyer_credit_user_address_change" value="">
  32. <input type="hidden" name="no_shipping" value="0">
  33. <input type="hidden" name="no_note" value="1">
  34. <input type="hidden" name="currency_code" value="USD">
  35. <input type="hidden" name="lc" value="US">
  36. <input type="hidden" name="bn" value="Cart">
  37. </form>
  38.  
Sep 6 '07 #1
Share this Question
Share on Google+
1 Reply


ak1dnar
Expert 100+
P: 1,584
check this out !
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="amount" value="<?Php echo mem_cost(); ?>">
Sep 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.