PDA

View Full Version : PHP links script



Cutter
11-08-2004, 04:20 PM
I noticed a lot of sites use asp for their external links. The link will be something like http://www.website.com/links/goto.asp?id=9999

Is there a way to do this in PHP? I have limited programming knowledge.

The reason I am asking is because I want to block outgoing PR for certain links on a page I am working on.

Thanks!

abelony
11-08-2004, 08:21 PM
Sure, here is a little piece of code for a url like this: http://www.website.com/links/goto.php?id=9999

The code below will be your goto.php file




If (!Isset($id)){
$URL="anywher you want to direct the user"; //if the $id is not set
}
else
{
// If you have the url stored in a database you can run a
//query here and get the URL that the visitor will be sent to.
}

header ("Location: $URL"); //This will send your visitor to the URL.

abelony
11-08-2004, 08:30 PM
Forgot to mention that you can tell the spider not to follow the link by putting the following code in a robots.txt file.

User-agent: *
Disallow: /links/goto.php

Anyone, if you notice a mistake please let us know. This is my very first programming advice. :)

s2kinteg916
11-08-2004, 09:38 PM
where do u set the id of the url ?

AndyH
11-08-2004, 09:46 PM
where do u set the id of the url ?


If (!Isset($id)){
$URL="anywher you want to direct the user"; //if the $id is not set
}
else
{
if ($id == 1) { $URL = "http://www.google.com"; }
elseif ($id == 2) { $URL = "http://www.msn.com"; }
elseif ( $id == 3) { $URL = "http://www.yahoo.com"; }
}

header ("Location: $URL"); //This will send your visitor to the URL.

Like that

s2kinteg916
11-08-2004, 10:09 PM
Cool thanks very useful...

Cutter
11-08-2004, 11:23 PM
Excellant, I appreciate the help.