Need a way to prevent user refreshing page - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-17-2012, 03:19 PM   #1 (permalink)
Junior Member
 
Join Date: Jan 2012
Posts: 1
Default Need a way to prevent user refreshing page

Hi everyone, I have a problem with a piece of code I have just written for my website and am hoping some genius here can help me out!

Basically I have a php script that when executed, will increase a database value by x. The value is received from a hook in the order system after an invoice has been paid.

Unfortunately, when refreshing the page the script repeats itself, and due to the way its written it increases the database value depending on what it is at the time its executed. For example:

Script executes -
Database value is Y -
Script adds X to Y -
Script calculates the new Y value and updates database -
Script ends -

If the user refreshes the script, they will be able to continuously repeat the database update adding X each time they refresh the page. I am only a beginner developer and have no idea how to stop this!

If anyone could suggest any methods of preventing this I would be very grateful!

Thanks
Fearghal is offline   Reply With Quote
Sponsored Links
Old 03-22-2012, 08:59 AM   #2 (permalink)
Regular User
 
Join Date: Mar 2012
Posts: 16
Default Re: Need a way to prevent user refreshing page

Use a redirect page after Update Query....here is the function
function redirect($link)
{
if (! headers_sent())
{
header("Location: $link");
}
else
{
echo "<script language=Javascript>document.location.href='$link' ;</script>";
}
exit(0);
}

Cheers
John
heads is offline   Reply With Quote
Old 04-24-2012, 11:34 AM   #3 (permalink)
Junior Member
 
Join Date: Apr 2012
Posts: 7
Default Re: Need a way to prevent user refreshing page

why not set a cookie when its been updated, and check for it
tommeh is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:03 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting