raptor30506090 Posted June 21, 2012 Share Posted June 21, 2012 Hi guys and girls Just a quick question just to get me started with my problem. Can any one point me in the right direction how to use form options with session im trying to build a shopping cart with size options with diffrent prices how do i go about this, if some one add to cart option 1 at 1.99 and then add option 2 at 2.99 how do i get this to work in a session Many thanks Daz or if you now of any website that mite be usful that also would be great Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted June 21, 2012 Share Posted June 21, 2012 I suggest that you use opensource cart such as opencart. Nonetheless, you would have to learn some php to get around it. I suggest you check this tutorial out. Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355742 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 Thanks for your fast reply Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355752 Share on other sites More sharing options...
ZulfadlyAshBurn Posted June 21, 2012 Share Posted June 21, 2012 No problem. If you have any problems, do share with us. Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355755 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 here is one im stuck on if(isset($_GET['add'])){ $cart = 'cart_'; if(isset($_SESSION[$cart . (int)$_GET['add']])){ $_SESSION[$cart . (int)$_GET['add']] ++; }else{ $_SESSION[$cart . (int)$_GET['add']] = '1'; } is this the ideal way to do session check and how do i stop it from adding to cart on the refresh many thanks Daz Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355759 Share on other sites More sharing options...
Porl123 Posted June 21, 2012 Share Posted June 21, 2012 What you could do is add a sort of captcha to the link. A random string of characters that will be kept in a session and regenerated every page load. That way people will be able to add more than one of the same item and it won't re-add an item if you reload the page. Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355760 Share on other sites More sharing options...
Porl123 Posted June 21, 2012 Share Posted June 21, 2012 Or, a much simpler way could be to called header("Location: shopping.php"); Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355761 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 Thanks for that do like that idea just been having a play think i could get that to for thanks Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355764 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 Porl123 what do you mean im not sure what your saying Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355767 Share on other sites More sharing options...
Porl123 Posted June 21, 2012 Share Posted June 21, 2012 Well I'd probably be tempted to do something like this: http://pastebin.com/dfEMgbWR Someone correct me if that's not a very good way. Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355769 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 mmm that is what i was just playing around with but if they press add to cart again then it would be relisted is this right? Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355771 Share on other sites More sharing options...
Porl123 Posted June 21, 2012 Share Posted June 21, 2012 Yeah, the random string of characters is generated on the first visit to the page, then it's regenerated every time the user adds an item to the basket. If they're attempted to use the code from the previous page load the add will fail. However the links will use the new code that's saved to the session. Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355773 Share on other sites More sharing options...
raptor30506090 Posted June 21, 2012 Author Share Posted June 21, 2012 thanks for your help ill have a play see what i can come up with cheers Quote Link to comment https://forums.phpfreaks.com/topic/264550-sessions/#findComment-1355774 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.