473,383 Members | 1,846 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,383 software developers and data experts.

getting the previous url

hi,

Is it possible to get the previous url. For example, if I am on page -
page01.php - and I then click to - page02.php - from page02.php, can I
use script to determine that I have come from page01.php? It doesnt
have to be the entire url, even just the file name. Cheers

Burnsy
Jul 17 '05 #1
5 26763
mr_burns wrote:
Is it possible to get the previous url. For example, if I am on page -
page01.php - and I then click to - page02.php - from page02.php, can I
use script to determine that I have come from page01.php? It doesnt
have to be the entire url, even just the file name. Cheers


The only reliable way you can get it is to pass it as a parameter to the
page eg your link would be page02.php?referer=page01.php, or use some
form of non-cookie sessions (which also require a parameter to be
passed in the url eg page02.php?sessid=123) and track it in a database.

You can use $_SERVER['referer_url'] but this is not always set; some
users have browser preferences or other software which prevents the
referal informtion being passed to the server for privacy/security
reasons.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
mr_burns wrote:
Is it possible to get the previous url. For example, if I am on
page -
page01.php - and I then click to - page02.php - from page02.php, can
I
use script to determine that I have come from page01.php?


You use $_SERVER["HTTP_REFERER"] ... however it must be noted that as
with *anything* that comes from client, this is unreliable
information; user can set it to whatever with the right tools. You
also can not rely that this information exists at all. Most of the
time it does, but if your system hangs up just because this info isn't
available, you're just putting yourself into a lot of trouble.

--
Markku Uttula

Jul 17 '05 #3
Hi,

Yeh, $_SERVER["HTTP_REFERER"] didnt return anything. I have tried
using instead, $_SERVER["PHP_SELF"], and that does the trick.

Is there anything I should be aware of when using $_SERVER["PHP_SELF"]?
Its really just for a simply 'send page to a friend'. If somebody was
to mess up the from address, it wouldnt do them any favours.

Burnsy

Jul 17 '05 #4
bi******@yahoo.co.uk wrote:
Yeh, $_SERVER["HTTP_REFERER"] didnt return anything. I have tried
using instead, $_SERVER["PHP_SELF"], and that does the trick.


Umm... PHP_SELF is the *current* page ... I understood you wanted to
know the page from which the user came to the current page.

--
Markku Uttula

Jul 17 '05 #5
mr_burns wrote:
Is it possible to get the previous url. For example, if I am on page - page01.php - and I then click to - page02.php - from page02.php, can I use script to determine that I have come from page01.php? It doesnt
have to be the entire url, even just the file name. Cheers


Add this line in the beginning of every script or possibly using a
global-common include file say config.php

output_add_rewrite_var('referer',
htmlspecialchars($_SERVER['PHP_SELF']));

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #6

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

Similar topics

11
by: mikey_boy | last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP script with makes a simple connection to a mysql database called firstdb and just pulls back the results and displays on the...
3
by: serge | last post by:
I am using SQL Server 7 SP4. I have created a blank database in which i am trying to import using DTS wizard all tables/views/stored procedures without any DATA (records). I keep getting...
5
by: Peter | last post by:
I am looking for a data structure that I need to use as follows. Suppose I am looking for node A. When I perform a lookup for node A I also want information about the node previous to node A( as...
1
by: msnews | last post by:
Hi All, My client has following request. I am not sure how to do it. Dynamically from database, we are getting set of images names. Now we want to display them with next and previous buttons....
4
by: devi | last post by:
Hi, In oracle I have a LAG function using which I could get the previous value of a field. Do we have anything similar to that in SQL Server or access? Thanks Devi
7
by: Hitesh | last post by:
Hi, I have a small script here that goes to inside dir and sorts the file by create date. I can return the create date but I don't know how to find the name of that file... I need file that is...
0
by: Maximus | last post by:
Hi to all, i am getting unable to cast error while using Me.previous page in asp.net 2.0 . i am using previous page object to getting values from public properties of previous page and i am...
1
by: Reb | last post by:
Hi all, I have not successfully found a Javascript sample for getting next and previous links from a file... I figured that someone must have solved this problem already! ... here is what I'm...
1
by: patronise | last post by:
My problem is that I'm wrestling to make the LoadMovie and UnloadMovie functions work for me. Here is the layout of my flash file: I've got several seperate flash files and I can jump to any one of...
0
by: navinkumarnischal | last post by:
From page1 i am redirecting to page2 in this pageload event i am redirecting to page3. In page3 if i give page.urlreffer the i will get page1 url but i want page2 url here how to get it and I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...

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.