URL variables not working

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
JeanPHP
Forum Newbie
Posts: 1
Joined: Mon Feb 02, 2004 9:50 am
Location: Herentals - Antwerp - Belgium

URL variables not working

Post by JeanPHP »

Hi, I have a small problem...
I installed EasyPHP (latest version) on my PC and it seems that URL variables do not work there...
So... If I put a <a href="index.php?page=home">HOME</a>
the index.php page tells me that variable $page does not exists...
What did I do wrong, How can I fix this problem? :oops:

Thanx in advance...

JeanPHP
Belgium
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Then there is somethine wrong with your code. Post your code, otherwise we wont know what the problem is....
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

have you added

Code: Select all

session_start();
at the top of you page?

have you

Code: Select all

//defining variable
$page = blahblahblah
defined the variable?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Hey malcolmboston,

The variable $page is being defined in the url

ie. http://www.site.com/?page=blah
So why would you define the variable as something else... sorta defeats the purpose?

The rest we can't help you with unless you provide some code :S
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

how do you fetch the page variable in the url?

using $_GET['page'] ??

show us your code
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You could also do something like this to display what page is being defined in the url

ie.

if $page == home {
include("home.php");
} elseif ( $page == "page2" ) {
include("home.php");
}

or

$page= $_REQUEST['page'];
if($page)
{
include($page. ".php");
} else
{
include("404.php");
}

Do not use the 2nd way if your going to have passwords/usernames or anything that is a security issue for obvious reasons
Post Reply