Author Topic: Grabbing urls  (Read 448 times)

0 Members and 1 Guest are viewing this topic.

Offline ShaolinFTopic starter

  • Enthusiast
  • Posts: 314
    • View Profile
Grabbing urls
« on: August 11, 2007, 02:04:46 PM »
Hi Guys,

Is there anyway of me grabbing the previous link the user has been on ? Say for example the user was on www.awebsite.com and then clicks my link through that site, is it possible for a script or something to grab the www.awebsite.com url ?

Offline ILYAS415

  • Enthusiast
  • Posts: 279
    • View Profile
Re: Grabbing urls
« Reply #1 on: August 11, 2007, 02:09:45 PM »
Try using this code:
Code: [Select]
<?
$url= $_SERVER['HTTP_REFERER']; //GET THE REFERRING URL
echo "You have just came from $url!";
?>
16 Years old. PHP & MySQL, Javascript, html, dhtml etc etc :p

Offline LiamProductions

  • Enthusiast
  • Posts: 498
    • View Profile
Re: Grabbing urls
« Reply #2 on: August 11, 2007, 02:10:22 PM »
Hmmm not sure if this works but i've heard about it.

Code: [Select]
<?php 
$url 
$_SERVER['HTTP_REQUEST'];

echo 
$url;


might not work but you might understand how to get it by looking at the http request.
Quote
In this hour, Your going to get your hands dirty with some of the nuts and bolts in the language

Offline ILYAS415

  • Enthusiast
  • Posts: 279
    • View Profile
Re: Grabbing urls
« Reply #3 on: August 11, 2007, 02:30:55 PM »
Neither of them seem to work on my site. Their must be something wrong with my server :@ annoying server :[
16 Years old. PHP & MySQL, Javascript, html, dhtml etc etc :p

Offline LiamProductions

  • Enthusiast
  • Posts: 498
    • View Profile
Re: Grabbing urls
« Reply #4 on: August 11, 2007, 02:41:14 PM »
HTTP REQUEST gets the url your on i think. But the one the other guy posted should work.
and does your php server support php short tags if not use <?php and sorry my code was missing a ?>

My server doesnt support short tags and it works if i use the full tag try it ;)
« Last Edit: August 11, 2007, 02:43:11 PM by LiamProductions »
Quote
In this hour, Your going to get your hands dirty with some of the nuts and bolts in the language

Offline ILYAS415

  • Enthusiast
  • Posts: 279
    • View Profile
Re: Grabbing urls
« Reply #5 on: August 11, 2007, 03:09:00 PM »
hehe i am the other guy who posted the $_SERVER['HTTP_REFERER']; command. I tried it on my own server but it didnt work
16 Years old. PHP & MySQL, Javascript, html, dhtml etc etc :p

Offline LiamProductions

  • Enthusiast
  • Posts: 498
    • View Profile
Re: Grabbing urls
« Reply #6 on: August 11, 2007, 04:21:18 PM »
hehe i am the other guy who posted the $_SERVER['HTTP_REFERER']; command. I tried it on my own server but it didnt work

It works for me. Just does'nt update it inless i close the browser then re open it.
well achually it only works if im using the link on a page on my website.
« Last Edit: August 11, 2007, 04:22:55 PM by LiamProductions »
Quote
In this hour, Your going to get your hands dirty with some of the nuts and bolts in the language