Click to See Complete Forum and Search --> : how to pass value through includes


kumar005
02-01-2006, 07:00 AM
$abc=$_SESSION['id'];
include("file2.php?$var=$abc");

bathurst_guy
02-01-2006, 07:03 AM
What is your question?

LiLcRaZyFuZzY
02-01-2006, 07:37 AM
from what i understand, you are asking how to pass a variable from a page to a page that is included.
It is not necessary, because the page will be included, the variables as well. The 2 pages will form 1 page, you can use the variables in file2.php without passing them through the GET or SESSION superglobals


<?php
# This is the main file: 'file1.php'
$greeting1 = "Hello, this is page 1<br>";
echo $greeting1;
include "file2.php";
echo $greeting2;
?>


<?php
# This is file 2: 'file2.php'
$greeting2 = "Hi, this is page 2";
?>