I am trying to find/create a simple script that will tell me where a coded link lands. For example
http://www.awin1.com/tclick.php?id=11738&mid=72 lands at http://www.groovychocolate.com
I want to be able to input the awin url and output the groovychocolate url
Any ideas?
Rgds
How can I?
Moderator: General Moderators
-
geekdesign
- Forum Newbie
- Posts: 1
- Joined: Thu Mar 04, 2004 3:46 pm
I hope I understand what you want so if the does not help can you be a little more specific. You want something like what they are doing.
First somewhere you have a table with some informations of links and whatever where each one has it own ID or something.
Second you create a script I don't know call it redirect.php or somthing like that. In that script you want to do the following.
I hope this helps.
First somewhere you have a table with some informations of links and whatever where each one has it own ID or something.
Second you create a script I don't know call it redirect.php or somthing like that. In that script you want to do the following.
Code: Select all
<?php
//Connect to database
//You may want to use error checking I am just stopping errors by using the @ sign
$link_id = @mysql_connect("host", "username", "password");
//Select your database
@mysql_select_db("database", $link_id);
//Query for pulling links from table
$query = "SELECT url_link FROM table_name WHERE url_id = '$url_id';";
//Get the results from the query
$results = @mysql_query($query, $link_id);
//Fetch the results
$row = @mysql_fetch_row($results);
//Get the url
$my_url = $row[0];
//Close the database
@mysql_close($link_id);
//Redirect to the page
header("Location: " . $my_url);
exit;
?>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
or by making the request to that page and parse the Location header
. Here is an example:
use it as follows:
http://yourhost.com/yourscript.php?chec ... 738&mid=72
Code: Select all
$check=$_GET["check"];
$cx=curl_init($check);
curl_setopt($cx,CURLOPT_HEADER,true);
curl_setopt($cx,CURLOPT_NOBODY,true);
curl_setopt($cx,CURLOPT_RETURNTRANSFER,true);
$ret=curl_exec($cx);
preg_match("/Location: (.*)/",$ret,$matches);
echo $matches[1]."\n";http://yourhost.com/yourscript.php?chec ... 738&mid=72