473,394 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

browser.history and log file

Rg
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.
Jul 17 '05 #1
2 5349
"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
Jul 17 '05 #2
"kingofkolt" <je**********@comcast.net> wrote in message news:<5%MSc.247246$IQ4.109595@attbi_s02>...
"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


2 solution without javascript

(1) you can use $_SERVER['HTTP_REFERER']. that contains the previous
url. note that not all browser sent this and that some browsers allow
the user to fake it.

(2) use a session in each of your pages to first read the previous url
and then store the present url (which then becomes the previous url on
the next page). this works obviuosly only if you want to monitor
movement inside your site).

you could also combine the 2 solution, i.e. use session if a previous
url in the session is set and $_SERVER['HTTP_REFERER'] as fallback.

micha
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
4
by: Rg | last post by:
Hello, I am very beginner with jscript. 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...
2
by: Michael G | last post by:
Can the browser back button or browser caching be turned on or off via php? Thanks, Mike ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----...
3
by: Rob | last post by:
Each time a webform is posted back (submitted), another URL is added to the browser's history list. My web application allows a back button to return to previously visited pages, but I do not wish...
6
by: David | last post by:
A user logs into a web site. He is then redirected to a web page of his choosing - based on menu options - for example: "WeeklyReport.aspx" is a page the user is currently viewing If the user...
1
by: disaia | last post by:
How can I access the History List of the User's browser from my ASP.NET page? Is there a way to do this? Thanks, Dominic Isaia disaia@earthlink.net
2
by: | last post by:
I am working on an ASP.NET application that seems to be limiting browser histories to only one entry. I am not using SmartNavigation on any of the pages, and that is the only thing that I have...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
2
by: Vighneswar | last post by:
Hi All Please let me know is there any way to clear the address bar history ( Typed URLs) of Firefox browser programmatically. Deleting 'index.dat' under profiles folder of firefox will delete...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.