Hi All

I would be greatfull if somebody could help me out with this one. ive been scratching my head all day in trying to find a solution. I have a order confirmation page which displays the entire order on a shopping cart. this page inserts a row into table tblorders of all the info about the order, before thte user is then re directed to the paypal page. The problem is: every time the page is refreshed it inserts a new row, or if the user clicks the back page then re directs to the orderconfirm page again it inserts a new row. I was wondering if anybody out there had a solution for this?

PLEASE HELP!!!!

Recommended Answers

All 8 Replies

Member Avatar for diafol

refreshing causing a duplicate entry points to the fact that you're processing form data in the same page as the form itself. You should send form data to a separate file by using the action attribute in the form tag.

You can always redirect back to the form page from the handler page by using header().

You won't notice the skip back and forth, but refresh (or back button) no longer causes the problem.

hi, thanks 4 the response so quickly. there is a couple of issues. the sql query is not in a form, and just executes when the form is loaded. 2nd the form on orderconfirm.php is a form specifically designed for paypal as per paypal instructions, to send to the paypal server. is there a way to use cookies? say for example when the user 1st loads the page, set a cookie with a value of 1. incriment the cookie by 1 at the bottom of the page. put the sql code in an if statement testing if the cookie value is greater than 1 dont execute the sql insert query? not too sure if this would work. i did experiment but couldnt get it to work? any ideas?

ops, sorry, typo error 1st line, executes when the page is loaded not form

Member Avatar for diafol

Well, it suggests that there is form handling going on that isn't triggered properly. A form on a page may trigger isset($_POST[..]) on page load.

could i use cookie value and increment it by 1 everytime the page is loaded, then use an if statement to check if the value of cookie is less than 1, execute the insert query? could that be away around it?

the thing is im not posting anything to this page. only posting the paypal form to paypal servers?

Member Avatar for diafol

Can you post the code? otherwise I'm just guessing. Strip out the keys and ids though. We don't want your info.

sure i will post it tomorrow. thanks 4 your support so far :o)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.