passing a variable from one php file to another

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
okee
Forum Newbie
Posts: 5
Joined: Thu Jan 16, 2003 4:48 pm

passing a variable from one php file to another

Post 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
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post 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
Post Reply