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
https://forums.phpfreaks.com/topic/33698-alternate-links/
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
https://forums.phpfreaks.com/topic/33698-alternate-links/#findComment-158023
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
https://forums.phpfreaks.com/topic/33698-alternate-links/#findComment-158734
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
https://forums.phpfreaks.com/topic/33698-alternate-links/#findComment-158772
Share on other sites

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.