473,564 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 26774
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?refe rer=page01.php, or use some
form of non-cookie sessions (which also require a parameter to be
passed in the url eg page02.php?sess id=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_REFER ER"] ... 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_REFER ER"] 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_REFER ER"] 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_rewr ite_var('refere r',
htmlspecialchar s($_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
2251
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 webpage. Here is the script. I appreciate any light that could be shed on the script and why I would get the errors. Thank you,
3
1886
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 different errors when importing the views and/or the SPs. I've tried many things unsuccessfully. Now even after the error msg of the DTS, i see some of...
5
1802
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 per the lookup data structure ordering scheme). Is there anything that I could use for this. Using a doubly linked list is not looking good as I can...
1
3207
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. I am able to pull all the information from database and put it in javascript array. Now using two functions for next and previous button, I am able...
4
4141
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
2079
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 not latest but was created before the last file. Any hints... I am newbiw python dude and still trying to figure out lot of 'stuff'..
0
925
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 using PostbackUrl to post the form. Most Interesting thing is that when i just replace same page from my development environment without making any...
1
2409
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 trying to do. I have a multi-framed file, with navigation in a top bar. Within each content directory, I have a file called nav.txt that lists the...
1
2389
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 them by pressing a specific key to load another flash file. Here is the code I'm using for this bit: Now when the next flash file is loaded, I...
0
1105
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 dont want to save the page2 url in session or query strings and so on... thanks in advance....
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.