Page 1 of 1

URL variables not working

Posted: Mon Feb 02, 2004 9:50 am
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

Posted: Mon Feb 02, 2004 9:53 am
by Illusionist
Then there is somethine wrong with your code. Post your code, otherwise we wont know what the problem is....

Posted: Mon Feb 02, 2004 10:59 am
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?

Posted: Mon Feb 02, 2004 11:57 am
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

Posted: Mon Feb 02, 2004 12:12 pm
by AVATAr
how do you fetch the page variable in the url?

using $_GET['page'] ??

show us your code

Posted: Mon Feb 02, 2004 12:27 pm
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