PDA

View Full Version : PHP Passing Variables


ianhull
07-05-2005, 08:41 AM
Hi guys,

Can anyone please help with passing variables to nextpage.php but not displaying them?

or provide any ideas on how to store all the variables which a displayed on my first page globally?

Also this session thingy how does this work?
I think that it works like this but if someone could confirm it that would be great.

use a session start on the first page, this will give a unique number and letter combination created by the server something like a4s877dsr8943jc09kkl
and throughout the site the user will keep this same identifier session number?

What I have upto now is a select dropdown box which retrieves a mysql column called companyname from my table customers.
After selecting the company and pressing next my next page has a sql query which selects companyname, companyaddress, telephone, extention, fax, postcode, email, website FROM customers WHERE companyname =form1 from the last page.

All these columns are then stored in variables with the column name ie $companyname, $fax etc

What I would like to do is have all these variables stored globally so that I do not have to keep querying the database.

Any ideas how I would achieve this?

Thanks in advance :)

Corey
07-05-2005, 05:03 PM
When you pass variables using the GET method they show up in the URL, when you pass them using the POST method they don't. Check this out for a better explanation than I can probably write. :)
http://www.google.ca/search?hl=en&q=difference+between+post+and+get&spell=1

ianhull
07-06-2005, 04:34 AM
Thanks Corey,

I seem to grasp the get and post methods now but I am still struggling with this session thingy.

Say I have $fax and $company and a include to a session.php how would I store the value of $fax and $company in the session for later retrieval throughout my other pages which also have the sample include session.php?

Kind regards

Ian

ianhull
07-06-2005, 04:43 AM
I think that I have now worked it out with this tutorial

http://www.zend.com/zend/tut/session.php

I should be using session_register("$fax"); //etc after I have queried my db

Then on all my other pages I should be using session_start(); //I think

Thanks for help guys :yes

I will get there one day.

Corey
07-06-2005, 05:10 AM
Sounds like you're doing pretty well already. :) The guys at Zend are great. :yes