Ajax + PHP session制作购物车

2019-09-14 06:47:33丽君

7.购物车页面删除处理页面shanchu.php

<?php
session_start();

$sy = $_GET["sy"];

$attr = $_SESSION["gwc"];

if($attr[$sy][1]>1)
{
  $attr[$sy][1] = $attr[$sy][1]-1;
}
else
{
  unset($attr[$sy]);
  $attr = array_values($attr);
}
$_SESSION["gwc"]=$attr;

header("location:gouwuche.php");

8.账户余额页面zhanghu.php


<?php
session_start();
$uid = $_SESSION['uid'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><br />
<style type="text/css">
.list{ width:100%; height:30px; margin-top:10px; text-align:center; line-height:30px; vertical-align:middle}
</style>
</head>
<body>
<div style="width:100%; height:100px; background-color:#6CC">
  <h1 style="float:left">大苹果商城</h1>
  <a style="float:right; margin-top:40px" href="zhuxiao.php">注销</a>
</div>
<br />
<div style="width:100%; height:600px">
  <div id="left" style="width:20%; float:left">
    <a href="main.php"><div class="list">浏览商品</div></a>
    <a href="zhanghu.php"><div class="list">查看账户</div></a>
    <a href="gouwuche.php"><div class="list">查看购物车</div></a>
  </div>  
  <div id="right" style="width:80%; height:150px; float:left">

<?php
    include("../DBDA.class.php");
    $db = new DBDA();
    $sql = "select Account from login where UserName='{$uid}'";
    $result = $db->strQuery($sql);
    
    echo ("您的账户中还剩余".$result);
  ?>

  </div>
</div>

</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。