- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: PHP self and history
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "PHP self and history"
Collapse
-
If you stick a link on there saying "Back to home page" (or whatever seems suitable) and dress it up nicely, 99 people out of 100 will use that instead of the browser back button
-
This might be why a lot of sites use JavaScript to add items to a basket... Yes, that probably would mean resorting to cookies though!
Leave a comment:
-
Cheers again. You're right. Ever look at those things in online newspapers? 10 world's most boring cities or whatever, you scroll through the images and then have to do back 10 times to leave the page.
Bunged this at end of function, seems to work ok. For few people with no jscript a couple of extra clicks is no big deal anyway esp. if I put a continue shopping button on.
echo '<script type="text/javascript">window.history.back(); </script>';
PS Darn things should work how I want them to work, not how they should work!
Leave a comment:
-
That's not a PHP thing - it's an HTTP thing combined with the browser's history implementation. I'd expect anything to work that way. When I submit a form, I'm navigating to a new state. The fact that the form happens to bring me back to the same place shouldn't mean it's ignored by the browser history.Originally posted by xoggoth View PostFound problem with self calls in that the browser history gets longer and longer, so if user adds to cart twice he has to click back three times to return to the main page.
As an experiment, I turned off JavaScript (to prevent Ajax confusing matters and ensure I was working purely with HTTP and the browser history) and visited Amazon's home page. There I followed a link to some book's product page, then added it to my basket. On the "you added this to your basket" page I added one of the recommended items below that message to my basket. That landed me on the "you added this to your basket" page for the second product.
Then, using the back button: the first click took me back to the "yattyb" page for the first item;the second click took me back to the product page for the first item; and the third click took me back to the home page.
All this is exactly as one would expect, and sounds just like how yours is working.
Leave a comment:
-
PHP self and history
Fed up with these complicated, umpteen file freeware things that don't work so am trying to write my own simple shopping cart in PHP. I am far from expert in this language. Basic code on a single product page is:
<?php
if(isset($_POST['add']))
{
blah, blah - add cart item to database
}
?>
blah, blah HTML
<form name="checkout" method="post" action="" action="">
<button type="submit" name="add" value="add"/>Add to cart</button>
blah, blah more HTML
All works great but thought it was too easy. Found problem with self calls in that the browser history gets longer and longer, so if user adds to cart twice he has to click back three times to return to the main page. Can't delete history in PHP so is there a better way of structuring things? Or do I have to resort to cookies?
Much ta.Last edited by xoggoth; 22 October 2013, 20:14.Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Leave a comment: