[S] Variables and carrying them trough several php scripts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

[S] Variables and carrying them trough several php scripts

Post by Calimero »

PROBLEM
1) If I declare variables in 1.php - that's the script to which I submit the form, and start another 2.php script trough Header - command, are the variables entered in the 1.php still functional in the 2.php or do I need to declare them again, and if possible the code for that (3 Variables, no more), 2.php will query the database

Thanks ahead
Last edited by Calimero on Tue Jul 27, 2004 2:11 am, edited 1 time in total.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

if you want to use a variable in many pages using header.. you have to

1- you use a url like: http://www.myurl.com\page.php?variable=content
and you retreive the content use get method ($_GET variable)...

2- using sessions.. ($_SESSION). you store de variable in a variable session in page 1.php ($_SESSION['myvariable'] = value) and you retreive the value in page 2 with $_SESSION['myvariable'] (you have to session_start(); in the first line of each page.

;)
Post Reply