Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:04:13+00:00 2026-05-23T03:04:13+00:00

I am building my own php cart for the past week and I got

  • 0

I am building my own php cart for the past week and I got stuck in some issues.

I managed to add new items in the cart, and the URL looks like below.

http://blah-blah.com/order/index.php?action=add&id=84

The question is simple: How can I prevent from adding the same item again in the cart
if someone refreshes the page? Cause now every time someone refreshes the page, it changes the quantity to +1 for the specific item..

Also, after moving to the checkout page, if they press the back button in the browser, AGAIN the quantity will change to +1;

Any recommendations?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:04:13+00:00Added an answer on May 23, 2026 at 3:04 am

    Yea. Have them set, rather than increment the quantity.

    Also, you’d usually use POST (not GET) requests for this sort of action. Browsers know this and cunningly ask the user whether they want to re-submit POST data.

    The cleanest approach for your user may be to do the whole thing with AJAX. If they go “back”, they’ll just go back to the last page they visited without trouble. This would be equivalent to how comments on Stack Overflow are submitted: you cannot go “back” to your submission step and end up writing duplicate comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building my own torrent site and after doing some research I have
I'm building a new project and I'm having some debate over how it needs
Being as stubborn as it gets, I'm building my own PHP-based CMS and framework
I'm building my own custom RSS feed in PHP. I want the tag to
Im building an own php framework. I saw in other frameworks there are even
I'm building my own personal CMS right now with PHP and MySql and I'm
Interested in building my own drag'n'drop file uploader using JQuery/AJAX/PHP. Basically I want a
I have my own hand-rolled PHP MVC framework for some projects that I'm working
I am interested in building my own php framework for my personal use to
I am interested in building a parser for my own enjoyment using PHP. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.