Jump to content


Photo

How to prevent user from hitting refresh button


  • Please log in to reply
2 replies to this topic

#1 samantha_chan1

samantha_chan1
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 10 April 2006 - 08:18 AM

How could i prevent a user from hitting the refresh button in the browser?

If the user hit the refresh button, the data will then be posted to database as a new record with a new primary key which i have set it as an auto increment primary key. How can i avoid this from happening?

what is the difference between using (1)include "hello.php" and (2) header (Location:"hello.php");?

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 10 April 2006 - 08:20 AM

1.) No, you cannot stop them from refreshing. Just code better to prevent double entries.


2.) include loads the file into the current script, header("Location: xxx") will redirect you to that page.

#3 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 10 April 2006 - 08:33 AM

As an extra from Prismatic, you can disable or remove the submit button [in a form] after its been clicked to prevent users clicking it more than once but for this you'd need to add a little javascript to hide it once pressed - surprised how many people keep clicking adding more data on a slow connection.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users