Jump to content

[SOLVED] Setting variable values through the URL.


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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.