| | |
Passing Variables in Included File
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I think we don't need to pass a variable to an included file, it already has
access to all variables in the including script. It becomes part of the
script that is including it.
$page = 'partner';
include '../admin/addcustomer.php';
Now addcustomer.php will see that $page contains 'partner'.
access to all variables in the including script. It becomes part of the
script that is including it.
$page = 'partner';
include '../admin/addcustomer.php';
Now addcustomer.php will see that $page contains 'partner'.
Last edited by Shanti Chepuru; Oct 22nd, 2008 at 8:36 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Is the included file just basic PHP, or does it have classes/functions in it, if the file uses functions you may need to register the variable as a global variable within each function you want to use it in.
Otherwise, post up your code so we can see what you are doing.
Otherwise, post up your code so we can see what you are doing.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
•
•
Join Date: May 2008
Posts: 43
Reputation:
Solved Threads: 0
/*** The Links script called adminlinks.php***/
<?session_start();
$action=$_GET['action'] ;
switch ($action) {
case "partner_company":
include ("../admin/addcompany.php?page=partner");
break;
/********** The AddCompanyScript *********/
<?session_start();
if($_SESSION['utype']!='admin')
header("location:login.php");
if(!empty($_GET['page']))
$flag=1;
else $flag=0;
/****** Index2.php***********/
if($_SESSION['utype']=='admin')
{<? include("includes/adminlinks.php") ;?> }
/***********AddPartner Script******/
<?session_start();
if($_SESSION['utype']!='admin')
header("location:login.php");
$value=$_POST['radio_value'];
if($value=="company")
{
header("Location:index2.php?action=partner_company");
}
/**********************/
I know this is a little bit complicated But Here the Storyboard :
i got a table called partners by which the admin can add a partner ..this partner can be an individual or can be a company ..so i made the admin choose before adding whether he wants to add a partner or a partner_company so if the last was the case he should be directed to the addcompany script BUT with a variable called page=partner
<?session_start();
$action=$_GET['action'] ;
switch ($action) {
case "partner_company":
include ("../admin/addcompany.php?page=partner");
break;
/********** The AddCompanyScript *********/
<?session_start();
if($_SESSION['utype']!='admin')
header("location:login.php");
if(!empty($_GET['page']))
$flag=1;
else $flag=0;
/****** Index2.php***********/
if($_SESSION['utype']=='admin')
{<? include("includes/adminlinks.php") ;?> }
/***********AddPartner Script******/
<?session_start();
if($_SESSION['utype']!='admin')
header("location:login.php");
$value=$_POST['radio_value'];
if($value=="company")
{
header("Location:index2.php?action=partner_company");
}
/**********************/
I know this is a little bit complicated But Here the Storyboard :

i got a table called partners by which the admin can add a partner ..this partner can be an individual or can be a company ..so i made the admin choose before adding whether he wants to add a partner or a partner_company so if the last was the case he should be directed to the addcompany script BUT with a variable called page=partner
Try this in your switch statement:
php Syntax (Toggle Plain Text)
switch ($action) { case "partner_company": $_GET['page'] = 'partner'; // Define the page - variable will then be available in addcompany.php include ("../admin/addcompany.php"); break; }
Last edited by jt1; Oct 22nd, 2008 at 7:50 pm. Reason: typo
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- passing linked lists through functions?? (C++)
- passing data from one function to another in C (C)
- help with parrallel arrays (C++)
Other Threads in the PHP Forum
- Previous Thread: session variables
- Next Thread: Problem with Signup Code
| Thread Tools | Search this Thread |
ajax apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error errors execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google href htaccess html image include insert integration ip java javasciptvalidation javascript joomla keywords limit link login loop mail matching menu mlm multiple mysql number oop paypal pdf php problem query radio random recursion recursive regex remote script search server sessions shot sms soap source space sql subscription syntax system table tag tutorial tutorials update upload url validator variable video web xml youtube






