小型bbs论坛系统开发4 后台父板块添加/修改
2016-12-19 16:34
337 查看
本章主要学习了,统一验证处理及验证处理机制,我觉得还是比较重要的。
项目布局:
–father.module.add.php
–father.module.update.php
–inc/check.father.module.inc.php
父板块页 father.module.php:
父板块添加页 father.module.add.php:
父板块修改页 father.module.update.php:
项目布局:
–father.module.add.php
–father.module.update.php
–inc/check.father.module.inc.php
父板块页 father.module.php:
<?php include_once '../inc/config.inc.php'; include_once '../inc/mysql.inc.php'; $title = '父板块列表';//设置当前页面标题 $link = sql_connect(); ?> <?php include_once './inc/header.inc.php'; ?> <div id="main" style="height:1000px;"> <div class="title">父板块信息</div> <table class="list"> <tr> <th>排序</th> <th>版块名称</th> <th>操作</th> </tr> <?php $query ="select * from sfk_father_module"; $result = sql_execute($link,$query); while($data = mysqli_fetch_assoc($result)){ // 实际删除代码: // father.module.delete.php?id={$data['id']} $url =urlencode("father.module.delete.php?id={$data['id']}"); $returnUrl = urlencode($_SERVER['REQUEST_URI']); $deleteUrl = "confirm.php?url={$url}&returnUrl={$returnUrl}"; $html=<<<STRING <tr> <td><input class="sort" type="text" name="sort" /></td> <td>{$data['module_name']} id:[{$data['id']}]</td> <td> <a href="#">[访问]</a> <a href="father.module.update.php?id={$data['id']}&module_name={$data['module_name']}&sort={$data['sort']}">[编辑]</a> <a href="{$deleteUrl}">[删除]</a> </td> </tr> STRING; echo $html; } ?> </table> </div> <?php include_once './inc/footer.inc.php'; ?>
父板块添加页 father.module.add.php:
<?php include_once '../inc/config.inc.php'; include_once '../inc/mysql.inc.php'; include_once '../inc/tool.inc.php'; $title = '父板块添加';//设置当前页面标题 if(isset($_POST['submit'])){ $link = sql_connect(); $check_flag = 'add';//执行sql操作的方式 //验证表单验证文件: include_once './inc/check.father.module.inc.php'; // 执行插入操作 $query = "insert into sfk_father_module(module_name,sort) values('{$_POST['module_name']}',{$_POST['sort']})"; sql_execute($link,$query); if(mysqli_affected_rows($link) == 1){ skip('father.module.php','ok','添加父板块成功!'); }else{ skip('father.module.php','error','添加父板块失败!'); } } ?> <?php include_once './inc/header.inc.php';?> <div id="main" style="height:1000px;"> <div class="title" style='margin-bottom:20px;'>父板块添加</div> <form method="POST"> <table class="au"> <tr> <td>版块名称</td> <td><input type="text" name = 'module_name'/></td> <td>最大长度不得超过32个字符</td> </tr> <tr> <td>排序</td> <td><input type="text" name = 'sort' value = '0' /></td> <td>只能填写数字</td> </tr> </table> <input class="btn" type="submit" name="submit" value d780 ="添加" style='margin-top: 10px;'/> </form> </div> <?php include_once './inc/footer.inc.php'; ?>
父板块修改页 father.module.update.php:
<?php include_once '../inc/config.inc.php'; include_once '../inc/mysql.inc.php'; include_once '../inc/tool.inc.php'; $title = '父板块修改';//设置当前页面标题 $link = sql_connect(); //获取表单默认值 $query = "select * from sfk_father_module where id = '{$_GET['id']}'"; $result = sql_execute($link,$query); $data = mysqli_fetch_assoc($result); if(!isset($_GET['id']) || !isset($_GET['module_name']) || !isset($_GET['sort'])){ skip('father.module.php','error','当前url来路不明'); } if(!is_numeric($_GET['id'])){ skip('father.module.php','error','id参数传递失败'); } if(isset($_POST['submit'])){ //验证表单验证文件: $check_flag = 'update'; include_once './inc/check.father.module.inc.php'; $query ="update sfk_father_module set module_name ='{$_POST['module_name']}',sort = {$_POST['sort']} where id = {$_GET['id']}"; sql_execute($link,$query); if($_POST['module_name'] == $_GET['module_name'] && $_POST['sort'] == $_GET['sort']){ skip('father.module.php','ask','您没有做任何更改'); } if(mysqli_affected_rows($link) == 1){ skip('father.module.php','ok','修改父板块成功!'); }else{ skip('father.module.php','error','修改父板块失败!'); } } ?> <?php include_once './inc/header.inc.php';?> <div id="main" style="height:1000px;"> <div class="title" style='margin-bottom:20px;'>父板块修改</div> <form method="POST"> <table class="au"> <tr> <td>版块名称</td> <td><input type="text" name = 'module_name' value = '<?php echo $data['module_name'];?>' /></td> <td>最大长度不得超过32个字符</td> </tr> <tr> <td>排序</td> <td><input type="text" name = 'sort' value = '<?php echo $data['sort'];?>' /></td> <td>只能填写数字</td> </tr> </table> <input class="btn" type="submit" name="submit" value="修改" style='margin-top: 10px;'/> </form> </div> <?php include_once './inc/footer.inc.php'; ?>
相关文章推荐
- 小型bbs论坛系统开发5 后台子板块添加/修改
- 小型bbs论坛系统开发3 后台父板块展示/删除
- 小型bbs论坛系统开发9 前台父板块列表页
- 小型bbs论坛系统开发6 前台注册/登录页
- 小型bbs论坛系统开发1 需求分析
- 小型bbs论坛系统开发7 会员帖子发布页
- 小型bbs论坛系统开发2 模板页首页制作
- 小型bbs论坛系统开发8 首页
- 小型bbs论坛系统开发10 前台子版块列表页
- ASP.NET动态网站开发培训-25.论文管理系统(五、添加后台新增及修改功能)
- 打通前后端全栈开发node+vue进阶【课程学习系统项目实战详细讲解】(3):用户添加/修改/删除 vue表格组件 vue分页组件
- 基于Java Web技术开发的BBS论坛系统(原创+源码+论文)
- DXBBS V8.0 BBS论坛系统 简体中文正式版 [ 开发语言:ASP.NET 2.0 (C#) ]
- C++开发的论坛系统 - BBS
- 原创+源码 基于Java Web技术开发的BBS论坛系统
- 基于SSH开发的BBS论坛系统
- 使用 XForms 和 Ruby on Rails 开发小型门诊管理系统,第 3 部分:实现护士和医生 XForm
- DXBBS V8.1 BBS论坛社区系统下载
- 在blog中添加attachments功能 (修改系统Control)
- 利用Visual Basic和PLC开发小型监控系统