客车网上订票系统项目--票务管理、前端个人信息修改
1、今日完成任务:
(1)后端票务管理模块的票务列表显示以及添加、修改和删除操作。
(2)前端个人中心页面完成个人资料修改与后台数据库的绑定。
2、核心代码
ticket-list.php
<?php require_once '../function.php'; //显示所有数据 $sql="select * from ticketInfo where ticketStatus=1;"; $rows=sel($sql); //数据的个数 $sqlNum="select count(*) from ticketInfo where ticketStatus=1;"; $rowsNum=sel($sqlNum); ?> <?php if($rows){?> <table class="table table-border table-bordered table-hover table-bg table-sort"> <thead> <tr class="text-c"> <th width="25"><input type="checkbox" name="" value=""></th> <th width="80">班次</th> <th width="100">起始站</th> <th width="40">终点站</th> <th width="150">出发时间</th> <th width="150">到达时间</th> <th width="">已售票数</th> <th width="100">总票数</th> <th width="70">票价</th> <th width="70">状态价</th> <th width="100">操作</th> </tr> </thead> <tbody> <?php foreach ($rows as $key=>$value){?> <tr class="text-c"> <td><input type="checkbox" value="1" name=""></td> <td><u style="cursor:pointer" class="text-primary" onclick="member_show('<?php echo $rows[$key]['carName']?>','member-show.php?id=<?php echo $rows[$key]['id']?>','<?php echo $rows[$key]['id']?>','360','400')"><?php echo $rows[$key]['carName']?></u></td> <td><?php echo $rows[$key]['startPosition']?></td> <td><?php echo $rows[$key]['endPosition']?></td> <td><?php echo $rows[$key]['startTime']?></td> <td><?php echo $rows[$key]['endTime']?></td> <td><?php echo $rows[$key]['soldTicket']?>张</td> <td><?php echo $rows[$key]['totalTicket']?>张</td> <td><?php echo $rows[$key]['ticketPrice']?>元</td> <td class="td-status"><span class="label label-success radius">已启用</span></td> <td class="td-manage"><a style="text-decoration:none" onClick="member_stop(this,'<?php echo $rows[$key]['id']?>')" href="javascript:;" title="停用"><i class="Hui-iconfont"></i></a> <a title="编辑" href="javascript:;" onclick="member_edit('编辑','ticket-add.php?id=<?php echo $rows[$key]['id']?>','4','','510')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a> <a title="删除" href="javascript:;" onclick="member_del(this,'<?php echo $rows[$key]['id']?>')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont"></i></a></td> </tr> <?php }?> </tbody> </table> <?php }else{?> <p>暂无用户列表</p> <?php }?> </div>
ticket-addAction.php
<?php require_once '../function.php'; $id=$_GET["id"]; $carName=$_POST["carName"]; $startPosition=$_POST["startPosition"]; $endPosition=$_POST["endPosition"]; $startTime1=$_POST["startTime1"]; $startTime2=$_POST["startTime2"]; $startTime=$startTime1." ".$startTime2; $endTime1=$_POST["endTime1"]; $endTime2=$_POST["endTime2"]; $endTime=$endTime1." ".$endTime2; $soldTicket=$_POST["soldTicket"]; $totalTicket=$_POST["totalTicket"]; $ticketPrice=$_POST["ticketPrice"]; $ticketStatus=$_POST["ticketStatus"]; if($id!=0){ //修改 $sql="update ticketInfo set carName='$carName',startPosition='$startPosition',endPosition='$endPosition',startTime='$startTime',endTime='$endTime',totalTicket='$totalTicket',soldTicket='$soldTicket',ticketPrice='$ticketPrice',ticketStatus='$ticketStatus' where id=$id;"; $result=oper($sql); }else{ //添加 $sql="insert into ticketInfo (carName,startPosition,endPosition,startTime,endTime,totalTicket,soldTicket,ticketPrice,ticketStatus,addTime) values('$carName','$startPosition','$endPosition','$startTime','$endTime','$totalTicket','$soldTicket','$ticketPrice','$ticketStatus',now());"; $result=oper($sql); } echo "<script>"; echo 'parent.location.href="ticket-list.php";'; echo "parent.layer.closeAll();"; echo "</script>"; ?>
用户信息修改:
<?php session_start(); //需要判读一下有没有进行登录 如果有登录进行显示下面的页面 如果没有登录则进入登录界面 if(!isset($_SESSION["userAccount"])){ //存储一下当前url 用于登录成功之后跳回 $_SESSION["userUrl"]=$_SERVER['REQUEST_URI']; header("location:login.php"); die();//下面的代码不在执行 } //显示个人信息 require_once 'function.php'; $UserTel=$_SESSION["userAccount"]; $UserPwd=$_SESSION["userPwd"]; $sql="select * from UserInfo where userTel='$UserTel' and userPass='$UserPwd'"; $rows=sel($sql); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>个人中心-客车网上售票系统</title> <link rel="stylesheet" type="text/css" href="css/base.css"/> <link rel="stylesheet" type="text/css" href="css/userInfo.css"/> </head> <body> <!--头部--> <div class="header"> <div class="container clear"> <div class="left"><a href="home.php"><img src="img/logo_pc.png"/></a></div> <div class="right clear"> <ul class="nav left clear"> <li><a href="home.php">首页</a></li> <li><a href="ticketsOnline.html">在线订票</a></li> <li><a href="newsList.php">新闻公告</a></li> <li><a href="leftMessage.php">留言中心</a></li> <li class="active"><a href="userInfo.php">个人中心</a></li> </ul> <div class="right btns-links"> <a href="login.html">登录</a> <a href="register.html">注册</a> </div> </div> </div> </div> <!--个人中心--> <div class="userInfo-box"> <div class="container clear"> <div class="left w18"> <ul> <li> <h3>资料设置</h3> <a href="userInfo.php">个人资料</a> <a href="">常用旅客</a> </li> <li> <h3>我的订单</h3> <a href="">所有订单</a> <a href="">待支付订单</a> <a href="">已支付订单</a> </li> </ul> </div> <div class="right w80"> <div class="userInfo-ctn"> <h3><span>个人</span>信息</h3> <form action="userInfoAction.php?id=<?php echo $rows[0]['userId']?>" method="post"> <table border="0" cellspacing="15px" cellpadding=""> <tr> <td align="right" width="90px"><span class="red">*</span>昵称</td> <td><input class="ipt-txt" type="text" name="nickname" id="" value="<?php echo $rows[0]['nickname']?>" /></td> </tr> <tr> <td align="right" width="90px"><span class="red">*</span>密码</td> <td><input class="ipt-txt" readonly="readonly" type="password" name="password" id="" value="<?php echo $rows[0]['userPass']?>" /></td> </tr> <tr> <td align="right">性别</td> <td> <label><input <?php if($rows[0]['userSex']=='男'){ echo 'checked="checked"';}?> type="radio" name="sex" id="" value="男" />男</label> <label><input <?php if($rows[0]['userSex']=='女'){ echo 'checked="checked"';}?> type="radio" name="sex" id="" value="女" />女</label> </td> </tr> <tr> <td align="right"><span class="red">*</span>手机号码</td> <td><input class="ipt-txt" type="tel" name="userTel" id="" value="<?php echo $rows[0]["userTel"]?>" /></td> </tr> <tr> <td align="right">常用邮箱</td> <td><input class="ipt-txt" type="email" name="userEmail" id="" value="<?php echo $rows[0]["userEmail"]?>" /></td> </tr> <tr> <td align="right">地址</td> <td> <textarea class="ipt-txt" name="userAddress" rows="" cols=""><?php echo $rows[0]["userAddress"]?></textarea> </td> </tr> <tr> <td align="right"></td> <td> <input class="button" type="submit" id="submit" name="submit" value="保存" /> </td> </tr> </table> </form> </div> </div> </div> </div> <!--优势--> <div class="register-advantage"> <div class="container"> <ul class="clear"> <li class="clear"> <div class="advantage-img left"><img src="img/icon_pinpaibaozheng.png"/></div> <div class="left"> <h4>品牌保证</h4> <p>提供正规的购票服务</p> </div> </li> <li class="clear"> <div class="advantage-img left"><img src="img/icon_kuaisufankui.png"/></div> <div class="left"> <h4>快速反馈</h4> <p>第一时间短信通知</p> </div> </li> <li class="clear"> <div class="advantage-img left"><img src="img/icon_fangbiankuaijie.png"/></div> <div class="left"> <h4>方便快捷</h4> <p>车站直接取票上车</p> </div> </li> <li class="clear"> <div class="advantage-img left"><img src="img/icon_zhifufangbian.png"/></div> <div class="left"> <h4>支付方便</h4> <p>支付宝微信</p> </div> </li> </ul> </div> </div> <!--底部--> <div class="register-footer"> <p>客车网上售票系统官方电话 400-100-1234 0371-1234567 客车网上售票信息公示</p> <p>客车网上售票系统 Copyright©2020-2030 版权所有 XXXXXX网络科技有限公司 豫ICP备15030935号-1</p> </div> </body> </html>
userInfoAction.php
<?php require_once 'function.php'; $Id=$_GET['id']; $nickName=$_POST["nickname"]; $userSex=$_POST["sex"]; $userTel=$_POST["userTel"]; $userEmail=$_POST["userEmail"]; $userAddress=$_POST["userAddress"]; $sql="update UserInfo set nickname='$nickName',userSex='$userSex',userTel='$userTel',userEmail='$userEmail',userAddress='$userAddress' where userId=$Id;"; $result=oper($sql); header("location:userInfo.php?id=$Id"); ?>