Jump to content

Alternate Links


kiowa_jackson

Recommended Posts

Wow, just spent 10 mins trying to read the scrambled letters to register to post :P

Just getting in to php but am familiar with the very basics...I want to know if there is a way to make php show different pages depending on what link someone comes in from?

What I mean if there is a way to use the include() command display a variable that is controlled by the link to the page...so something like if someone clicks http://www.domain.com/index.php?a it takes them to an index site with one headline and if they click http://www.domain.com/index.php?b they get another.

I know these aren't the correct, but I'm wondering if there is something that achieves something similar?



Thanks
Link to comment
Share on other sites

[code]
<?php
  if (isset($_GET['page'])) {
    switch ($_GET['page']) {
      case 'news':
        include 'news.php';
      break;
      case 'about':
        include 'about.php';
      break;
      default:
        include 'index.php';
      break;
    }
  }
?>
[/code]

Then your links would look like... http://www.domain.com/index.php?page=news
Link to comment
Share on other sites

The script works great, but when I use the standard link it defaults to nothing...it looks like this
[code]
<?php
  if (isset($_GET['page'])) {
    switch ($_GET['page']) {
      case 'panic':
        include 'panic.php';
      break;
      case 'agoraphobia':
        include 'agoraphobia.php';
      break;
      default:
        include 'panic.php';
      break;
    }
  }
?>
[/code]

but it won't default to panic.php when I use the regular link(but it works well with the modified links)...what am I doing wrong?

Thanks
Link to comment
Share on other sites

[code]
<?php
  if (isset($_GET['page'])) {
    switch ($_GET['page']) {
      case 'panic':
        include 'panic.php';
      break;
      case 'agoraphobia':
        include 'agoraphobia.php';
      break;
      default:
        include 'panic.php';
      break;
    }
  } else {
    include 'panic.php';
  }
?>
[/code]
Link to comment
Share on other sites

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.