Creating Shopping Cart

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Mon Jan 03, 2005 8:29 am    Post subject: Creating Shopping Cart Reply with quote

Can someone give me some ifo on creating a shopping cart like the one paypal use.

like the paypal one but for my own server so on checkout it gose to paypal / whatever

addtocart.php?email=my@email.com&product=whatever&price=10

then it puts it on the page

and totals it up,

then at the bottom of the page a button that sends the total thing :)

if you can understand that thanks
if you give us any info or help thanks
Back to top View user's profile Send private message
GustavoDL
-


Joined: 08 Jul 2004
Posts: 16
Location: Malaga (Spain)

PostPosted: Mon Jan 03, 2005 3:46 pm    Post subject: safety Reply with quote

I recommend you to use session variables on guarding shopping values

$_SESSION['name']=value;

when no longer necessary delete it with unset(variable);
_________________
Think as WAN, act as LAN
Piensa en WAN, actua en LAN
Back to top View user's profile Send private message Visit poster's website
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Tue Jan 04, 2005 7:50 am    Post subject: Reply with quote

thanks for that i was going to use cookies but looking at php.net session sounds better

but how to add an item to the page and then another below that one
Back to top View user's profile Send private message
GustavoDL
-


Joined: 08 Jul 2004
Posts: 16
Location: Malaga (Spain)

PostPosted: Thu Jan 20, 2005 1:41 pm    Post subject: Reply with quote

You can/should use arrays:

to asing values (it's only an example, $item is the total of items in this sample)
Code:

for ($n=0;$n<$item;$n++){
    $_SESSION['item'][]="item".$n;
    }



Note that in PHP not asigned name/value to an array position (like in my example) is valid, PHP auto asigns the next value, so you can get all the content of an array in this way:
Code:

for ($n=0;$n<count($_SESSION['item' ]);$n++){
    echo $_SESSION['item'][$n]."<br>";
    }



PHP it's more flexible than COBOL :-P
_________________
Think as WAN, act as LAN
Piensa en WAN, actua en LAN
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group