Page 1 of 1

Passing variable to another pg w/o GET, POST or SESSION ??

Posted: Thu Aug 19, 2010 2:18 pm
by diseman
Hello Experts,

My level = beginner

I performed some simple math equations based on my form input. Basically, all I did was assign a variable to a few monthly bills, which I added and totaled. On another page, I wanted to use this variable I created in part of another calculation I was doing on that page. I currently am using SESSION to pass it over, but that doesn't work well because I have to view the first page first before viewing the second page or the variable doesn't get passed over. In fact, I get an error message until I visit the first page...

Here's what I'm doing as an example:

income page:

Code: Select all

$monthly_income = ($gross_pay + $commission) ;
Expense Page:

Code: Select all

 $monthly_expenses = ($electricity + $water + $mortgage) ; 
One additional calculation on the Expense Page:

Code: Select all

$My_disposable_income = ($monthly_income - $monthly_expenses);
Notice in the code box directly above - the $monthly_income is from another page. How do I get $monthly_income to work on the expense page?

Seems a lot of people ask this question, but everything I found was offering up GET, POST, & SESSIONS, which don't apply in my application.

I hope I've explained it well enough for you to understand.

Thank you in advance for any help...

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Thu Aug 19, 2010 2:28 pm
by AbraCadaver
Yes, sessions or post does apply in your case. How do you get from income page to expense page?

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Thu Aug 19, 2010 3:41 pm
by diseman
Hi,

When I login, I'm taken to a central page. From there, I have INCOME and EXPENSE links on the left. I have about 10 links on the left that I can go into at any time. Yes, I can go from INCOME to EXPENSE, but it's not always the case that I would do that or want to. In fact, I may just want to go to the EXPENSE page and then logout.

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Thu Aug 19, 2010 4:17 pm
by AbraCadaver
Sounds like you need to store this stuff in a database so that when you come back the data will be available.

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Thu Aug 19, 2010 6:13 pm
by diseman
Yeah, I've thought of that as well, but it doesn't appear to me that that's the best way. I'm not saying I know how, but it just seems like there has to be a better way.

Anyone else want to weigh in?

Thanks...

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Thu Aug 19, 2010 7:05 pm
by shawngoldw
database. Listen to the other Shawn


Shawn

Re: Passing variable to another pg w/o GET, POST or SESSION

Posted: Sun Aug 22, 2010 8:44 pm
by diseman
Still doesn't seem right to have to create extra database fields and then store calculations in there and then pull them on another page.

What I ended up doing was taking the calculations I wanted and put them in a separate .php page. I then INCLUDE (); the calculations on the page I need them and it works fine.