473,412 Members | 4,127 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,412 software developers and data experts.

Execute php with back button

Hi!!!!

I need that when the user goes back to the last page with the "Back"
button of the browser, the page executes the php code again.

Is there any code to insert in php that implies a reload every time the
page appears in the user browser??

Best regards!!!

Ezequiel

Dec 30 '05 #1
4 1792
zek2005 wrote:
I need that when the user goes back to the last page with the "Back"
button of the browser, the page executes the php code again.

Is there any code to insert in php that implies a reload every time the
page appears in the user browser??

Simply disable caching:

<?php

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

session_start();
if (!session_register("var")) {
session_register("var");
$_SESSION["var"] = 1;
} else {
$_SESSION["var"]++;
}

echo $_SESSION["var"];

?>

This will output 1 on first load,
Go to some other site, then hit back, and it will output 2 :)
luph
Dec 30 '05 #2
You could also try:

<form action="<?php print $_SERVER['HTTP_REFERER']; ?>" method="get">
<input type="submit" value="back">
</form>

Of course if the page was the result of a post than the method would have to
be changed accordingly.

Balazs

Is there any code to insert in php that implies a reload every time the
page appears in the user browser??

Dec 30 '05 #3
Lüpher Cypher <lu***********@verizon.net> wrote:

Simply disable caching:

<?php

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past


I've seen a number of different suggestions on disabling caching over the
years, with variations that worked some places but not in others.

Is this now the "canonical" recommended method of disabling caching of a
web page? Does this really catch all the major browsers and proxies,
including AOL's rather aggressive "accelerator"?
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 31 '05 #4
Tim Roberts wrote:
<?php

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past


I've seen a number of different suggestions on disabling caching over the
years, with variations that worked some places but not in others.

Is this now the "canonical" recommended method of disabling caching of a
web page? Does this really catch all the major browsers and proxies,
including AOL's rather aggressive "accelerator"?


Well, I'm not sure, as I haven't tested it on all browsers, but it
should work fine since it is a http1.1 standard ;)
luph
Jan 1 '06 #5

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

Similar topics

4
by: Fred | last post by:
I have read and tried every combination for hours. I'm sorry, but I don't get it. How do I have a form with textboxes and buttons and allow click events to execute a server function then display...
3
by: Lyle Fairfield | last post by:
MS-SQL Server utilities Enterprise Manager and Query Analyzer will model almost any MS-SQL object as a simple script file with a default ".sql" extension. But how to "run these files? They are...
3
by: Tim Marshall | last post by:
HI all, Access 2003, Jet back end. Rather than annoy my users in a particular app by having relationships with enforced relational integrity refuse to delete a record with related records, I'm...
4
by: Marcel Balcarek | last post by:
I want to create a button using code-behind that only executes javascript, and does not post back to the server. How can I do this - my ImageButton insists on posting back to the server. Thank...
1
by: M | last post by:
Hi everybody, I have a Web form with something like: <form id="Form1" method="post" onsubmit="javascript:submitForm();" runat="server"> I need the JavaScript function submitForm() to execute...
4
by: Ian Kelly | last post by:
Hi All, I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. ...
4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
0
by: oliver | last post by:
QUESTION: How to access an object embedded in a UserControl through Javascript file? Another way to ask this question: How to execute script from a UserControl, accessing other objects in that...
0
by: rathis | last post by:
Hi all. i'm developing a query search engine. front end is ASp and back end DB2. There are many queries listed in it. Now i want to place a execute button near each query and when clicking it it...
3
by: elrondrules | last post by:
Hi I am pretty new to PHP and hence need your help!! I need to write a PHP that shows the user a button (button1) and a series of check boxes and another button (button2).. If the button1...
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
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...
0
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...
0
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...

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.