[PHP] Function to remember costs.

2002-10-11 Thread Steve Jackson

I am having difficulty passing details to a form. 
I need to somehow pass a variable cost to a form. 
The cost is made up of items in a cart (details taken from a Mysql DB)
and a shipping cost. I then have a function written to display the
credit card form (which needs to be passed to a secure server below the
final cost  (ie cost plus shipping). I have tried without success most
of this morning to pass the final cost plus shipping to the form hidden
field (which is on the same html page!) Here is the section of code I am
having problems with. I will supply the rest of the functions to anyone
who thinks they can help but it's a lot of code.
 
 
 
?
}
 
function display_shipping($shipping)
{
  // display table row with shipping cost and total price including
shipping
  global $total_price;
?
  table border = 0 width = 760 cellspacing = 0
  trtd align = leftShipping/td
  td align = right ?=number_format($shipping, 2); ?/td/tr
  trth bgcolor=#146190 align = leftTOTAL INCLUDING SHIPPING/th
  th bgcolor=#146190 align = rightˆ
?=number_format($shipping+$total_price, 2); ?/th
  /tr
  /tablebr
?
}
 
function display_card_form($name)
{
  //display form asking for credit card details
?
  table border = 0 width = 760 cellspacing = 0
 
  form action ='https://spos.luottokunta.fi/pm/servlet/Payment'
method='post'
  input type='hidden' name='version' value='1.2'
  input type='hidden' name='merchant_rn' value='8058950'
  input type='hidden' name='order_rn' value='10001'
  input type='hidden' name='amount' value=''
  input type='hidden' name='amount_exp' value='-2'
  input type='hidden' name='currency' value='978'
  input type='hidden' name='order_description' value='Viola test
product'
  input type='hidden' name='success_url'
value='http://www.violasystems.com'
  input type='hidden' name='failure_url'
value='http://www.violasystems.com/bazaar'
  input type='hidden' name='cancel_url'
value='http://www.violasystems.com/privacy.php'
  input type='hidden' name='trans_method' value='0'
  input type='hidden' name='mac' value='F529BC531D'
  trth colspan = 2 bgcolor=#ccCredit Card Details/th/tr
  tr
tdType/td
tdselect name =
card_typeoptionVISAoptionMasterCard/select/td
  /tr
  tr
tdNumber/td
tdinput type = text name = card_number value =  maxlength = 16
size = 40/td
  /tr
  tr
tdAMEX code (if required)/td
tdinput type = text name = amex_code value =  maxlength = 4
size = 4/td
  /tr
  tr
tdExpiry Date/td
tdMonth select name =
card_monthoption01option02option03option04option05option06
option07option08option09option10option11option12/select
Year select name =
card_yearoption00option01option02option03option04option05o
ption06option07option08option09option10/select/td
  /tr
  tr
tdName on Card/td
tdinput type = text name = card_name value = ?=$name; ?
maxlength = 40 size = 40/td
  /tr
  tr
td colspan = 2 align = center
  bIf you press purchase your credit card details will be
transmitted via a secure
   server, your details processed and then you will be redirected to our
site./b
 ? display_form_button(purchase, Purchase These Items); ?
/td
  /tr
  /table
  
 
?
 
As you can see the PHP code is just a  part of one larger page of
functions.
What I am trying to do is pass the
?=number_format($shipping+$total_price, 2); ? to the amount hidden
field in the form.
Any ideas?
This is not all my code which is why I am having problems.

Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com http://www.violasystems.com/ 
[EMAIL PROTECTED]
Mobile +358 50 343 5159



 



RE: [PHP] Function to remember costs.[Scanned]

2002-10-11 Thread Michael Egan

Steve,

I've only had a quick glance at this but from the code you've posted you don't seem to 
be associating a variable with the hidden field you're referring to in the 
display_form function.

You need to store the amount in a variable and then refer to the variable in the value 
attribute of the hidden field.

Michael Egan

-Original Message-
From: Steve Jackson [mailto:[EMAIL PROTECTED]]
Sent: 11 October 2002 11:47
To: PHP General
Subject: [PHP] Function to remember costs.[Scanned]


I am having difficulty passing details to a form. 
I need to somehow pass a variable cost to a form. 
The cost is made up of items in a cart (details taken from a Mysql DB)
and a shipping cost. I then have a function written to display the
credit card form (which needs to be passed to a secure server below the
final cost  (ie cost plus shipping). I have tried without success most
of this morning to pass the final cost plus shipping to the form hidden
field (which is on the same html page!) Here is the section of code I am
having problems with. I will supply the rest of the functions to anyone
who thinks they can help but it's a lot of code.
 
 
 
?
}
 
function display_shipping($shipping)
{
  // display table row with shipping cost and total price including
shipping
  global $total_price;
?
  table border = 0 width = 760 cellspacing = 0
  trtd align = leftShipping/td
  td align = right ?=number_format($shipping, 2); ?/td/tr
  trth bgcolor=#146190 align = leftTOTAL INCLUDING SHIPPING/th
  th bgcolor=#146190 align = rightˆ
?=number_format($shipping+$total_price, 2); ?/th
  /tr
  /tablebr
?
}
 
function display_card_form($name)
{
  //display form asking for credit card details
?
  table border = 0 width = 760 cellspacing = 0
 
  form action ='https://spos.luottokunta.fi/pm/servlet/Payment'
method='post'
  input type='hidden' name='version' value='1.2'
  input type='hidden' name='merchant_rn' value='8058950'
  input type='hidden' name='order_rn' value='10001'
  input type='hidden' name='amount' value=''
  input type='hidden' name='amount_exp' value='-2'
  input type='hidden' name='currency' value='978'
  input type='hidden' name='order_description' value='Viola test
product'
  input type='hidden' name='success_url'
value='http://www.violasystems.com'
  input type='hidden' name='failure_url'
value='http://www.violasystems.com/bazaar'
  input type='hidden' name='cancel_url'
value='http://www.violasystems.com/privacy.php'
  input type='hidden' name='trans_method' value='0'
  input type='hidden' name='mac' value='F529BC531D'
  trth colspan = 2 bgcolor=#ccCredit Card Details/th/tr
  tr
tdType/td
tdselect name =
card_typeoptionVISAoptionMasterCard/select/td
  /tr
  tr
tdNumber/td
tdinput type = text name = card_number value =  maxlength = 16
size = 40/td
  /tr
  tr
tdAMEX code (if required)/td
tdinput type = text name = amex_code value =  maxlength = 4
size = 4/td
  /tr
  tr
tdExpiry Date/td
tdMonth select name =
card_monthoption01option02option03option04option05option06
option07option08option09option10option11option12/select
Year select name =
card_yearoption00option01option02option03option04option05o
ption06option07option08option09option10/select/td
  /tr
  tr
tdName on Card/td
tdinput type = text name = card_name value = ?=$name; ?
maxlength = 40 size = 40/td
  /tr
  tr
td colspan = 2 align = center
  bIf you press purchase your credit card details will be
transmitted via a secure
   server, your details processed and then you will be redirected to our
site./b
 ? display_form_button(purchase, Purchase These Items); ?
/td
  /tr
  /table
  
 
?
 
As you can see the PHP code is just a  part of one larger page of
functions.
What I am trying to do is pass the
?=number_format($shipping+$total_price, 2); ? to the amount hidden
field in the form.
Any ideas?
This is not all my code which is why I am having problems.

Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com http://www.violasystems.com/ 
[EMAIL PROTECTED]
Mobile +358 50 343 5159



 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php