日期:2011-04-19 浏览次数:20436 次
采于www.phpbuilder.com,稍作补充。代码如下。嘻嘻:)
basket.php:
<?php
include ("evert.inc");
?>
<PRE>
ID Name Price
1 Mouse 25.00 <A HREF="<?echo $PHP_SELF; ?>?act=add&id=1&price=25&basket=Mouse">add</A> <A HREF="<?echo $PHP_SELF; ?>?act=subtract&id=1&price=25&basket=Mouse">subtract</A>
2 Key 100.00 <A HREF="<?echo $PHP_SELF; ?>?act=add&id=2&price=100&basket=Key">add</A> <A HREF="<?echo $PHP_SELF; ?>?act=subtract&id=2&price=100&basket=Key">subtract</A>
3 Car 5000.00 <A HREF="<?echo $PHP_SELF; ?>?act=add&id=3&price=5000&basket=Car">add</A> <A HREF="<?echo $PHP_SELF; ?>?act=subtract&id=3&price=5000&basket=Car">subtract</A>
4 Game 25.00 <A HREF="<?echo $PHP_SELF; ?>?act=add&id=4&price=25&basket=Game">add</A> <A HREF="<?echo $PHP_SELF; ?>?act=subtract&id=4&price=25&basket=Game">subtract</A>
</PRE>
<a href="<?echo $PHP_SELF;?>?logout=1">Logout</a>
evert.inc:
<?php
session_start();
if($logout){
session_destroy();
unset($ses_basket_name);
unset($ses_basket_amount);
unset($ses_basket_price);
unset($ses_basket_id);
unset($ses_basket_items);
}
if ($basket!=""){
if (session_is_registered("ses_basket_items")){
$basket_position_counter=0;
$double=0;
if ($ses_basket_items>0){
foreach ($ses_basket_name as $basket_item){
if ($basket_item==$basket){
$double=1;
$basket_position=$basket_position_counter;
}
$basket_position_counter++;
}
}
if ($double==1){
$oldamount=$ses_basket_amount[$basket_position];