Jump to content

[SOLVED] Help with headers and Back Button please


Riparian

Recommended Posts

Scenario :

 

I add a product to the cart with a href call with the model number included.

 

e.g. <a href=$_SERVER[php_SELF]?model=1234>Add to cart</a>

 

On the page re-load model 1234 is added to cart. All fine so far...

 

The client then clicks to go to the cart

 

e.g. <a href=cart.php>Cart</a>

 

Problem.....

 

If the client uses the Browser Back Button this URL reloads

 

<a href=$_SERVER[php_self]?model=1234>Add to cart</a>

 

Which adds another entry into the cart. How can i prevent this ?

 

Any help is greatly appreciated

Thanks for the input

 

Unfortunately both are not possible as I offer up to 100 products per page so I do not see how this be achieved any other way and  a client is at liberty to add 2 of the same model number to the cart ( 2 must be added individually for later processing)

 

Is there no other way ?

I have figured a work around.

 

Only record an entry if a session variable is set in the add program.

 

Unset the session variable in the cart program so if they use the browser back button the entry will not be re-recorded.

 

Unless anyone can see a downside to this method then perhaps this will help someone else.

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.