作者:凡秘能 | 来源:互联网 | 2023-05-17 11:50
本章主要学习了,统一验证处理及验证处理机制,我觉得还是比较重要的。项目布局:–father.module.add.php–father.module.update.php–i
本章主要学习了,统一验证处理及验证处理机制,我觉得还是比较重要的。
项目布局:
–father.module.add.php
–father.module.update.php
–inc/check.father.module.inc.php
父板块页 father.module.php:
include_once '../inc/config.inc.php';
include_once '../inc/mysql.inc.php';
$title = '父板块列表';
$link = sql_connect();
?>
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>
$query ="select * from sfk_father_module";
$result = sql_execute($link,$query);
while($data = mysqli_fetch_assoc($result)){
$url =urlencode("father.module.delete.php?id={$data['id']}");
$returnUrl = urlencode($_SERVER['REQUEST_URI']);
$deleteUrl = "confirm.php?url={$url}&returnUrl={$returnUrl}";
$html=<<
|
{$data['module_name']} id:[{$data['id']}] |
[访问] [编辑] [删除] |
STRING;
echo $html;
}
?>
table>
div>
include_once './inc/footer.inc.php'; ?>
父板块添加页 father.module.add.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';
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','添加父板块失败!');
}
}
?>
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="添加" style='margin-top: 10px;'/>
form>
div>
include_once './inc/footer.inc.php'; ?>
父板块修改页 father.module.update.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','修改父板块失败!');
}
}
?>
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 = ' echo $data['module_name'];?>' />td>
<td>最大长度不得超过32个字符td>
tr>
<tr>
<td>排序td>
<td><input type="text" name = 'sort' value = ' echo $data['sort'];?>' />td>
<td>只能填写数字td>
tr>
table>
<input class="btn" type="submit" name="submit" value="修改" style='margin-top: 10px;'/>
form>
div>
include_once './inc/footer.inc.php'; ?>