"Rg" <sp**@me.again> wrote in message
news:Xn*************************@195.131.52.135...
Hello,
I am very beginner with PHP. I have an Apache PHP enabled
webserver and want to know from where users are coming from.
Understand I want the last surfer's browser visited url.
I imagine I can do this with some kind of interraction
between 2 scripts : one client side, one server side.
The client one send the URL and the server one write it
in the right log file.
I have no idea of how to do this nor with principle nor
with syntax ...
Can somebody help with a few lines *working* example?
Any idea appreciated!
Thanks
Rg.
First you need to set up a little JavaScript to get the variable of the URL
you're looking for (my JavaScript is a little rusty so I can't tell you the
exact code to get it). Suppose you name the variable "url". So put this
script in some page that the visitor will see:
<script language="javascript">
url = (however you get the URL);
document.write( "<img src='log.php?url=" + url + "' width='1'
height='1'>" );
</script>
Then in log.php, use $_GET['url'] to access the URL and insert it into a
database (or whatever you wanted to do with it).
- JP