doudi7782 2014-01-19 13:14
浏览 34

PHP Cookie:从购物车中删除商品

I am wanting to display items to the user by using cookies, I have run into an issue where when wanting to delete a single cookie from the list nothing happens. For each record that is displayed to the user there will be a delete button. Currently when the delete button is clicked the cookie value does not get set to a blank value. For initial testing the only cookie that will be set to blank is cookievalue1

if (isset($_REQUEST['attempt']))    {

if (isset($_POST['sound1']))    {
    $intwoMonth = 60 * 60 * 24 * 60 + time();
    setcookie("cookievalue1","",$intwoMonth);
}

}


$i = 1;
$x = 4;

$username = "Username";
$orderno = "0353627";
$item1 = "Bread";
$price1 = "$50";
$item2 = "Cheese";
$price2 = "$46";
$subtotal = "$96";
$tax = "5%";
$total = "$100";
$var = NULL;

$cookiearray = array($username,$orderno,$item1,$price1,$item2,$price2,$subtotal,$tax,$total);   
print_r($cookiearray);  print '<br></br>';  print '<br></br>';

while ($i < $x) {   


 $cookiearray1 = serialize($cookiearray);

 setcookie("cookievalue" . $i, $cookiearray1, time()+3600);
 print '<br></br>';

 $var = unserialize($cookiearray1);


 $var2 = unserialize($cook1);
 print $var2[$i];
 print '<br></br>';print '<br></br>';

print '
<body>
<form action="cookieandarray6.php?attempt" method="post"/>
<input type="delete" name="sound1" value="sound1"<br><br>
<input type="submit" value="Delete"/>
</form>
</body>';

print '<br></br>';print '<br></br>';
$i = $i + 1;
}




?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题