Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,462 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,362 people online right now. Registration is fast and FREE... Join Now!




Can I Tell If A User Has Hit Refresh Or Reload?

 
Reply to this topicStart new topic

Can I Tell If A User Has Hit Refresh Or Reload?, also POST vs database retrieval....

DanceInstructor
post 24 Mar, 2005 - 08:32 AM
Post #1


New D.I.C Head

Group Icon
Joined: 18 Mar, 2005
Posts: 41



Dream Kudos: 25
My Contributions


I would like to know if there is any way php can know if a user has reloaded or refreshed a page?

I am working on a script that retrieves data from the database and will allow the user to sort the data in several different ways. Is it better to retrieve the data from the database every time the data is resorted or pass the data through POST to the new page?

Thanks smile.gif

This post has been edited by DanceInstructor: 24 Mar, 2005 - 08:37 AM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 24 Mar, 2005 - 10:59 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,173



Thanked 33 times

Dream Kudos: 25
My Contributions


I'm not sure if there is a direct php method for detecting a refresh...perhaps cyberscribe, supersloth, or skyhawk knows one. You could use the event handler onUnload in the body tag, using that trigger to call a server side script to do what you need.

To be honest, I'd suggest that the easier course of action would be to pass the new parameter to the refreshed page (the sort in this case), and rerun the query using that parameter as the ORDER BY clause.
User is online!Profile CardPM

Go to the top of the page

DanceInstructor
post 24 Mar, 2005 - 04:26 PM
Post #3


New D.I.C Head

Group Icon
Joined: 18 Mar, 2005
Posts: 41



Dream Kudos: 25
My Contributions


Thanks for your reply.

biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 24 Mar, 2005 - 05:18 PM
Post #4


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


QUOTE(DanceInstructor @ Mar 24 2005, 09:32 AM)
I would like to know if there is any way php can know if a user has reloaded or refreshed a page?

If refresh means "second viewing of the page" the cookies are your solution here.

QUOTE

I am working on a script that retrieves data from the database and will allow the user to sort the data in several different ways.  Is it better to retrieve the data from the database every time the data is resorted or pass the data through POST to the new page?


Depends on how much data we are talking about. smile.gif

So -- which one are you -- the guy in the cowboy hat or the gal in the big pink dress?
User is offlineProfile CardPM

Go to the top of the page

DanceInstructor
post 24 Mar, 2005 - 06:36 PM
Post #5


New D.I.C Head

Group Icon
Joined: 18 Mar, 2005
Posts: 41



Dream Kudos: 25
My Contributions


Now that I think about it. If I made a hidden form I would essentially double the amount of data I'm sending to the user. I think I will just query the database each time.

QUOTE(cyberscribe)
So -- which one are you -- the guy in the cowboy hat or the gal in the big pink dress?


I'm the guy in the cowboy hat. Does that mean I get less help? tongue.gif

This post has been edited by DanceInstructor: 24 Mar, 2005 - 06:39 PM
User is offlineProfile CardPM

Go to the top of the page

cyberscribe
post 24 Mar, 2005 - 09:14 PM
Post #6


humble.genius

Group Icon
Joined: 5 May, 2002
Posts: 1,062



Thanked 2 times

Dream Kudos: 154
My Contributions


QUOTE(DanceInstructor @ Mar 24 2005, 07:36 PM)
I'm the guy in the cowboy hat. Does that mean I get less help? tongue.gif

No way, dude. Happy to see a new face in the PHP forums.

Personally, I couldn't dance with people shooting at my feet, but I know a thing or two about PHP...
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 24 Mar, 2005 - 09:20 PM
Post #7


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,844



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


This is a common problem, I personally just repass the parameters as hidden form fields and rerun the query, it's not so much a refresh as it is a onChange=" submit()" This will submit a hidden form on the page and the value of a drop down menu with the onChange event. You'll want to rerun the query to sort.

You can also capture the query string from the URL and append it to your URL's if you're going to do links at the top of each column.
User is offlineProfile CardPM

Go to the top of the page

DanceInstructor
post 25 Mar, 2005 - 12:40 PM
Post #8


New D.I.C Head

Group Icon
Joined: 18 Mar, 2005
Posts: 41



Dream Kudos: 25
My Contributions


I was actually thinking of using list boxes (same as drop downs right?), you can see an example near the bottom of this page. Of course my version would be simpler as I won't have so much info. What do you think of a list box versus links at the top of a column?

Thanks for all the info guys biggrin.gif

This post has been edited by DanceInstructor: 25 Mar, 2005 - 12:44 PM
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 25 Mar, 2005 - 02:39 PM
Post #9


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,844



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


We use list boxes on a bunch of applications at work, I use an onChange="submit()"; and then do something to the effect of

[seudo code]
if (isDefined $firstbox) { query for second box }
[/seudo code]
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 12:52PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month