Tricky question about usage of $_POST, Hyperlinks and MVC

Post Reply
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Tricky question about usage of $_POST, Hyperlinks and MVC

Post by Neofriend » Sat Dec 18, 2010 12:59 pm

Hey Neo and Everyone Else,

I've been learning PHP lately and have been making my own small MVC framework using switch cases. It works well, is simple and does the job.

Now, first question, I have a view file, a product page basically... for some products, I have a some questions and some choices for the buyer to choose from... Now I'd like that when add to cart button is pushed, it should save those added product custom selected options to the session as well. Is that possible?

I tried giving an hyperlink a name and such variations to make it work but it didn't. WIth that, please let me mention here that I'd like to save its options in to session via the add to cart controller logic.... there I mean.

Secondly...... is there any good way of implementing this logic in PHP? As i shared above. I've been stuck at this since very long and its really disturbing me.... I cannot get this specific part of coding thing....

Lots more to do, please guide. Thanks.
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: Tricky question about usage of $_POST, Hyperlinks and MVC

Post by Saman » Sat Dec 18, 2010 5:38 pm

Now, first question, I have a view file, a product page basically... for some products, I have a some questions and some choices for the buyer to choose from... Now I'd like that when add to cart button is pushed, it should save those added product custom selected options to the session as well. Is that possible?
Yes of cause, this is possible. This is how the shopping carts are usually handled.

You can keep 3 session keys as below.

Number_of_products
product_code_array[0..(N-1)]
product_option_array[0..(N-1)]

Whenever a new product is added, you increase Number_of_products by one. Then other arrays are updated with information.

See How to store an Array in a Session in php.
Pansophic
Sergeant
Sergeant
Posts: 25
Joined: Sun Feb 13, 2011 4:05 pm

Re: Tricky question about usage of $_POST, Hyperlinks and MVC

Post by Pansophic » Tue Mar 01, 2011 2:36 pm

I maybe able to help you on this, PM me if you still looking for help.
Post Reply

Return to “PHP & MySQL”