PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
gangboy
Forum Newbie
Posts: 14 Joined: Tue Jan 06, 2004 11:58 am
Location: Constanţa, România
Post
by gangboy » Thu Jan 08, 2004 10:10 am
If for example I call link.php like this:
http://localhost/link.php?page=yahoo
how should link.php look?
This is an ideea of mine but my PHP knowledge is very limited:
Code: Select all
<?php
if (!empty($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "$null";
}
if ($page == "yahoo") {
header("Location:http://www.yahoo.com/");
}
?>
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu Jan 08, 2004 10:18 am
what you had was okay, but you would have to hard code loads of header locations.
what about this
Code: Select all
<?php
if (!empty($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "null";
}
if ($page != "null") {
header("Location:http://www.$page.com/");
} else {
echo "no link selected";
}
?>
Mark
gangboy
Forum Newbie
Posts: 14 Joined: Tue Jan 06, 2004 11:58 am
Location: Constanţa, România
Post
by gangboy » Thu Jan 08, 2004 10:20 am
That would work; but what if the page has another tld (ie: instead of .com would be .ro)?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu Jan 08, 2004 10:21 am
yup, that would be a problem
why not have your link like
http://localhost/link.php?page=www.yahoo.com
then
Code: Select all
<?php
if (!empty($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "null";
}
if ($page != "null") {
header("Location:http://$page");
} else {
echo "no link selected";
}
?>
Mark
gangboy
Forum Newbie
Posts: 14 Joined: Tue Jan 06, 2004 11:58 am
Location: Constanţa, România
Post
by gangboy » Thu Jan 08, 2004 10:23 am
That was the original ideea and I guess that should do it in the end.
Thanks!