Forum Moderators: coopster

Message Too Old, No Replies

Get Referer

Snippets?

         

nedloh

10:58 am on Jul 18, 2007 (gmt 0)

10+ Year Member



Whenever i use anything to get the referer it turns up blank. I want to get the refering URL and then get a Query from that. IS there anyway? lol This is agravating me. I keep trying and can't even get a snippet on doing it. Please help i would be willing to pay for a script that does this!

finoo

11:24 am on Jul 18, 2007 (gmt 0)

10+ Year Member



Try :
<?

$clienturl = $_GET['clienturl'];

mysql_query("INSERT INTO database VALUES ('$clienturl)");

echo "User came from $clienturl";
?>

nedloh

11:40 am on Jul 18, 2007 (gmt 0)

10+ Year Member



But i don't want it as a MySQL Db. All i want it to get the refering URL then get the query from it. Then redirect there. lol.

finoo

11:55 am on Jul 18, 2007 (gmt 0)

10+ Year Member



Im not sure what you are trying to do.

nedloh

12:07 pm on Jul 18, 2007 (gmt 0)

10+ Year Member



Okay. The URL will be mysite.com/download.php?downloadsite.com/asdasd/asdasd/asd/asd/sad
Now, I need to find the referer then get the downloadsite.com part of it. Then Redirect there. I have it so it does it in a frame. (making a premium link grabber a friend made but never finished)

dreamcatcher

12:22 pm on Jul 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$_SERVER['QUERY_STRING'] will get your data from the query string. Or you could use $_SERVER['REQUEST_URI'];

$array = explode("/", $_SERVER['REQUEST_URI']);

echo '<pre>';
print_r($array);
echo '</pre>';

dc

nedloh

12:33 pm on Jul 18, 2007 (gmt 0)

10+ Year Member



Thanks Dreamcatcher. That works but how would i then use that to redirect to the actual page? All that does is print the Array lol. Thanks for all the help though!

whoisgregg

1:56 pm on Jul 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello nedloh! Redirects are done using the header [php.net] function. Take care to send the appropriate redirect status (301, 302, etc.) as that choice can have implications in the search engines.

dreamcatcher

2:43 pm on Jul 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As whoisgregg mentioned really nedloh. To manipulate the array, just access the slot you need:

$array[0];
$array[1];

etc

dc

nedloh

1:47 pm on Jul 24, 2007 (gmt 0)

10+ Year Member



This is waht i have now. But it won't redirect. header("Location: "http://" .$array[4]. .$array[5]. .$array[6]. );
exit;

?>
Any ideas?

PHP_Chimp

1:50 pm on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you getting an error where it says headers already sent?

As either you need to buffer the output or send your headers as the first thing i.e. if you have started to send (x)html then you cant send additional headers.

PHP_Chimp

1:52 pm on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



("Location: "http://" .$array[4]. .$array[5]. .$array[6]. );

you only need 1 . to concentrate the strings together

("Location : http://" .$array[4].$array[5].$array[6]);

[edited by: eelixduppy at 2:22 pm (utc) on July 24, 2007]
[edit reason] delinked [/edit]

nedloh

1:39 am on Jul 27, 2007 (gmt 0)

10+ Year Member



Thanks PHP_Chimp although that doesn't work. Is there a way to set the referer to a custom referer? I would then use the querystring from the set referer to redirect.