refresh while submitting page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
khoemf
Forum Newbie
Posts: 1
Joined: Tue Feb 16, 2010 8:53 pm

refresh while submitting page

Post by khoemf »

HI all

I am new in this forum.

I have a question is that there is a page "actionA.php" which take time to do lot of thing (e.g get a file list form master table, checking each file exist, then copy one by one ,more that 1000 file and write a record to DB for that user). While processing, some user refresh the page , as a result there are duplicate /wrong record (file list) for the user. How can i avoid user to refresh the page while submitting page (in client level or server level). I have studied about "Post Redirect Get Pattern" but it seems not work.

Thanks All
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: refresh while submitting page

Post by jraede »

You can use session variables. Just set something like $_SESSION['user_ran_script'] to TRUE after the script executes, and then on the first line do a conditional to see if that variable is set.
Post Reply