php中address,address.php

require"include/common.inc.php";

header("Cache-control: private");

session_start();

require "include/cart_class.php";

?>

$cart=new usercart();

//获取操作状态

$action=isset($_GET['action'])?html(trim($_GET['action'])):'';

//添加在地址

if($action=='add'){

$fullname=isset($_GET['fullname'])?html(trim($_GET['fullname'])):'';//收货人

$provinceid=isset($_GET['province'])?html(trim($_GET['province'])):''; //省

$cityid=isset($_GET['city'])?html(trim($_GET['city'])):''; //市

$districtid=isset($_GET['district'])?html(trim($_GET['district'])):''; //区

//通过省份id查询省份的名称

$province = $db->getQueryAllRow('select title_lm from qu_lm where id_lm='.$provinceid.'');

//通过城市的id查询城市的名称

$city = $db->getQueryAllRow('select title_lm from qu_lm where id_lm='.$cityid.'');

//通过地区的id查询地区的名称

$district = $db->getQueryAllRow('select title_lm from qu_lm where id_lm='.$districtid.'');

//详细的地址信息

$address=isset($_GET['address'])?html(trim($_GET['address'])):'';

//获取邮箱

$email=isset($_GET['email'])?html(trim($_GET['email'])):'';

//获取邮编

$post=isset($_GET['post'])?html(trim($_GET['post'])):'';

//获取手机号码

$phone=isset($_GET['phone'])?html(trim($_GET['phone'])):'';

//获取固定电话

$tel=isset($_GET['tel'])?html(trim($_GET['tel'])):'';

if($fullname=='' || $province=='' || $city=='' || $district=='' || $address=='' || $phone==''){

exit();

}

//插入用户收货地址表

$db->execute('insert into person_addr(username,fullname,province,city,district,address,email,post,phone,tel,wtime) values("'.$_SESSION['usernames'].'","'.$fullname.'","'.$province.'","'.$city.'","'.$district.'","'.$address.'","'.$email.'","'.$post.'","'.$phone.'","'.$tel.'",'.time().')');

//通过用户名查询用户的收货地址

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" order by id desc';

$result=$db->query($sql);

//获取所有的收货地址并且返回

while(!!$row = $db->getRow($result)){

?>

type="radio" name="mId" value="<?php echo $row['id']?>" />收货人:<?php echo $row['fullname']?>    地址:<?php echo $row['province']?><?php echo $row['city']?><?php echo $row['district']?><?php echo $row['address']?>    邮编:<?php echo $row['post']?>    邮箱:<?php echo $row['email']?>

   电话:<?php echo $row['phone']?> <?php echo $row['tel']?>     [ 删除 ]

}

$db->freeResult($result);

}elseif($action=='del'){//删除地址

//获取地址id

$id=isset($_GET['id'])?html(trim($_GET['id'])):'';

//检查合法性

if($id=='' || !checknum($id)){

exit();

}

//通过地址id和用户名查询用户地址信息

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" and id='.$id.'';

$result=$db->query($sql);

//判断订单是不存在

if(!!$row = $db->getRow($result)){

$db->execute('delete from person_addr where username="'.$_SESSION['usernames'].'" and id='.$id.'');

}

$db->freeResult($result);

//

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" order by id desc';

$result=$db->query($sql);

while(!!$row = $db->getRow($result)){

?>

type="radio" name="mId" value="<?php echo $row['id']?>" />收货人:<?php echo $row['fullname']?>    地址:<?php echo $row['province']?><?php echo $row['city']?><?php echo $row['district']?><?php echo $row['address']?>    邮编:<?php echo $row['post']?>    邮箱:<?php echo $row['email']?>

   电话:<?php echo $row['phone']?> <?php echo $row['tel']?>     [ 删除 ]

}

$db->freeResult($result);

}elseif($action=='save'){//保存地址

//通过用户名查询用户地址

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" order by id desc';

$result=$db->query($sql);

//获取所有的用户地址

while(!!$row = $db->getRow($result)){

$db->execute('update person_addr set ok=0 where username="'.$_SESSION['usernames'].'"');

}

$db->freeResult($result);

//获取地址id

$id=isset($_GET['id'])?html(trim($_GET['id'])):'';

if($id=='' || !checknum($id)){

exit();

}

//通过用户名和地址id查询地址信息

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" and id='.$id.'';

$result=$db->query($sql);

if(!!$row = $db->getRow($result)){

$db->execute('update person_addr set ok=1 where id='.$id.'');

}

$db->freeResult($result);

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" order by id desc';

$result=$db->query($sql);

while(!!$row = $db->getRow($result)){

?>

type="radio" name="mId" value="<?php echo $row['id']?>" />收货人:<?php echo $row['fullname']?>    地址:<?php echo $row['province']?><?php echo $row['city']?><?php echo $row['district']?><?php echo $row['address']?>    邮编:<?php echo $row['post']?>    电话:<?php echo $row['phone']?> <?php echo $row['tel']?>     [ 删除 ]

}

$db->freeResult($result);

}elseif($action=='look'){

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" and ok=1 order by id desc limit 1';

$result=$db->query($sql);

if(!!$row = $db->getRow($result)){

?>

*收货人:<?php echo $row['fullname']?>
*收货地区:<?php echo $row['province']?><?php echo $row['city']?><?php echo $row['district']?>
*详细地址: <?php echo $row['address']?>
邮政编码:<?php echo $row['post']?>
*手机号码:<?php echo $row['phone']?>  

固定电话:

}

$db->freeResult($result);

}elseif($action=='again'){

$sql='select * from person_addr where username="'.$_SESSION['usernames'].'" order by id desc';

$result=$db->query($sql);

while(!!$row = $db->getRow($result)){

?>

type="radio" name="mId" value="<?php echo $row['id']?>" />收货人:<?php echo $row['fullname']?>    地址:<?php echo $row['province']?><?php echo $row['city']?><?php echo $row['district']?><?php echo $row['address']?>    邮编:<?php echo $row['post']?>    电话:<?php echo $row['phone']?> <?php echo $row['tel']?>     [ 删除 ]

}

$db->freeResult($result);

}

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值