Jump to content

[SOLVED] Setting variable values through the URL.


DavidGS

Recommended Posts

I know this is a rather trivial question, but how do I go about setting the value of  a variable through a URL? Like, say you had a page which has "tabs" and for each tab you want to display different content. To make sure the user sees the right tab, you would use something like http://example.com/index.php?tab=1

 

When I try to set the value of a variable that way it doesn't return anything.

 

print "$pageid";

 

with the URL http://localhost/index.php?pageid=1

 

Nothing is printed because pageid doesn't have a value.

 

But if I try defining the variable in the script:

 

$pageid = 1;

 

It returns whatever value I defined it with instead.

 

What is right way of using variables in your URL?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.