Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - solution to prevent page from reloading??
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

solution to prevent page from reloading??

 Post Reply Post Reply
Author
probichaud View Drop Down
Newbie
Newbie


Joined: 12 November 2003
Location: Canada
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote probichaud Quote  Post ReplyReply Direct Link To This Post Topic: solution to prevent page from reloading??
    Posted: 13 November 2003 at 11:41am

Hello,

does anyone know of a simple asp solution/script to prevent duplicate credit card transactions/submissions from occurring?

I have a credit card processing page that I don't want users to be able to reload/refresh. This causes a additional request to the payment gateway resulting in a duplicate transaction. I thought about doing a database check on user name first but was hoping there would be a better solution...

Thanks for any suggestions or insight on this problem.

probichaud.

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 13 November 2003 at 12:29pm
You can create a unique GUID or Session ID on entering the site. Use that in the database as the purchase Key and if someone hits refresh raise an error that the form has already been submitted. I wouild clear that variable though after checkout in case the customer decides to come back and purchase something else.
Back to Top
probichaud View Drop Down
Newbie
Newbie


Joined: 12 November 2003
Location: Canada
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote probichaud Quote  Post ReplyReply Direct Link To This Post Posted: 13 November 2003 at 12:45pm

Good idea! Thanks a lot.

 

Back to Top
rjohnmatts View Drop Down
Newbie
Newbie


Joined: 05 December 2003
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote rjohnmatts Quote  Post ReplyReply Direct Link To This Post Posted: 05 December 2003 at 12:40pm

Another way to do this is to use a javascript function to store the current time in a hidden field.  When the page is submitted, call the function, and then submit the page. Server Side, store the value in the session, and just check the incoming value to see if it is the same as the one stored in the session.

example:

  //Client code:
  function preventResubmit(){
   //this function will insert the current time into the preventResubmit field
   //the value will be stored in the session and a comparison will be made on subsequent actions to see if the time is the same
   //in the case that it is, the user will be logged out
   var theDate = new Date();
   var milliDate = theDate.getTime();
   document.formName.preventResubmit.value = millisDate;
  }
  <input type=hidden name=preventResubmit value="">
  
  //Server code:
  String sessionPreventResubmit = (String)session.getAttribute("preventResubmit");
  String clientPreventResubmit = (String)request.getParameter("preventResubmit");
  if(localPreventResubmit != null){
   if(sessionPreventResubmit.equals(localPrev entResubmit)){
    response.sendRedirect("error.htm");
   }
   else{
    session.setAttribute("preventResubmi t", localPreventResubmit);
    //jsp or servlet content here
   }
  }

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 05 December 2003 at 7:36pm
Another way is to post the data to a page other than the final destination and then do a redirect after processing. Then if they refresh the page they are only getting the final page which does not process CC again.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.