Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,487 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,709 people online right now. Registration is fast and FREE... Join Now!




Automated page redirection based on URL

 
Reply to this topicStart new topic

Automated page redirection based on URL

FliP1992
29 Feb, 2008 - 08:57 AM
Post #1

D.I.C Head
**

Joined: 14 Jun, 2007
Posts: 56


My Contributions
ive been doing my website,
ive been told to do php for the games page on my site.

can enyone point me to a tutorail or help me on here so when you:
click a name e.g metal slug the php will take this name and pease it to the right game that will be displayed a new page.

Thanks,
Tom
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Automated Page Redirection Based On URL
29 Feb, 2008 - 09:54 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,212



Thanked: 216 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
The idea is really simple, your script will need to read in the value passed and using the "header()" function simply pass the user to a URL. It might work something like this...

php

<?php

if (isset($_GET["game"])) {
// Store the name of the game into a variable (passed to the script via a url)
// Eg. www.mydomain.com/games.php?game=metalslug
$gamename = strtoupper($_GET["game"]);

// Now based on the game, we execute one of many choices.
// Each choice sending the user to the related game page.
switch ($gamename) {
case "METALSLUG":
header("Location: metalslug.php");
break;
case "PACMAN":
header("Location: pacman.php");
break;
case "SPACEINVADERS":
header("Location: spaceinvaders.php");
break;
default:
echo "Sorry, there is no game page for the game specified.";
}
}

?>


This is one way to do it and might be the easiest for you to implement and extend when you get more games online. Just don't start making the list hundreds of entries long. When that starts happening, you can come see us for more advanced techniques.

Hope that helps! smile.gif

"At DIC we be the game page rerouting code ninjas!"

This post has been edited by Martyr2: 29 Feb, 2008 - 09:56 AM
User is online!Profile CardPM
+Quote Post

SpaceMan
RE: Automated Page Redirection Based On URL
1 Mar, 2008 - 07:48 AM
Post #3

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

posable he asking that is a sub dir?
explode / php self
or a page name they are on?
php self = figure stuffs.

can modify the case switch he posted to display the links.

new window is easy, < a target=_new
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:29PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month