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
原始數據
按行查看
歷史
總結
以上是生活随笔為你收集整理的php中address,address.php的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 吃新疆撸串时,你还吃什么?
- 下一篇: 凪怎么读?