Solved

how to change a session variable using PHP

Posted on 2009-05-10
4
208 Views
Last Modified: 2012-05-06
Hi,

I have an order form that passes a price including shipping to Paypal. PayPal then confirms the user, determines the address, and returns the amount and address to a confirmation page form. From this page the user hits submit and the amount is passed and the transaction gets completed.

If the user has a California shipping address I have a function on the confirmation page that calculates the tax. The problem is I cannot get the newly tax calculated total passed in the final phase of the order process. So when he user hits submit from the order confirmation page the amount without the tax gets passed, not the amount with the tax that has been calculated.

This is the 4 steps of my order process.

Price page > Paypal > confirmation Page > Transaction complete page

The problem is, the Price generated at the Price page stays in the URL during the whole transaction. I need to change it at the Confirmation page and pass the new amount in the URL to the Transaction complete page.

Below is the code that I don't understand that I am hoping I can modify.


<!-- confirmation page -->
 

<!-- this is the tax calculation function, nothing wrong here, I just included it for explanation purposes -->
 

$caltax = (($_REQUEST['paymentAmount'] - $_REQUEST['SHIPPINGAMT']) * 0.0925);
 

if ($resArray['SHIPTOSTATE'] == 'CA')

{

$_REQUEST['paymentAmount'] = ($_REQUEST['paymentAmount'] + $caltax);               

}
 

<!-- this is the price variable who's value want to change but cannot figure out how to-->
 

$_SESSION['paymentAmount']=$_REQUEST['paymentAmount'];
 

<!-- Transaction complete page  -->
 

$paymentAmount =urlencode ($_SESSION['paymentAmount']);
 

<!-- This is the code that passes the final amount to complete the transaction  -->
 

$nvpstr='&TOKEN='.$token.'&PAYERID='.$payerID.'&PAYMENTACTION='.$paymentType.'&AMT='.$paymentAmount.'&CURRENCYCODE='.$currCodeType.'&IPADDRESS='.$serverName ;

Open in new window

0
Comment
Question by:jackie777
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:NeoDiffusion
ID: 24349280

Hello jackie777,

So far I remember, $_REQUEST['paymentAmount'] and $paymentAmount are two different variables, even if initially containing the same values. Meaning that if $_REQUEST['paymentAmount'] is modified but $paymentAmount is sent back, the original value is sent back, not the modified one (assuming the register global variable are still ON).

So, either do (in the confirmation page):
$paymentAmount = ($_REQUEST['paymentAmount'] + $caltax);  


or change the URL string to contain the modified value.

Rgds,

Werner.
0
 

Author Comment

by:jackie777
ID: 24349579
Thanks,

I wasn't getting that they were two different variables, so that was very helpful.

How would I change the URL string to contain the modified value?
0
 
LVL 10

Accepted Solution

by:
NeoDiffusion earned 500 total points
ID: 24349676
Just do the change proposed above:
$paymentAmount = ($_REQUEST['paymentAmount'] + $caltax);  

replacing
$_REQUEST['paymentAmount'] = ($_REQUEST['paymentAmount'] + $caltax);              

Rgds,
Werner.
0
 

Author Closing Comment

by:jackie777
ID: 31579936
Thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now