Page 1 of 1

passing a variable from one php file to another

Posted: Thu Feb 13, 2003 8:41 pm
by okee
Hi

I want to know how to pass a variable from one file (menu.php)
to another file (showinfo.php).
Say in menu.php if a user clicks on a link then it passes the variable
$Country to the showinfo.php file and this file contains a function
that outputs info about that country to the browser.

Do I need to include ("showinfo.php") in my menu file before i can access
it ?

Thanks

Rich

Posted: Thu Feb 13, 2003 8:59 pm
by lazy_yogi
there are a couple of ways to do that :

1. make the link

< a href=page.php?country=<?php echo $country ?> >

and then in the file page.php
to get the variable use
$country = $_POST['country'];
and u can use it there

or
2. u could use sessions