php安全开发 13博客系统的栏目模块的编写

创建cate_list.php

<?php
include_once "head.php";
include_once "../common/Page.class.php";

if ($_GET['action'] == 'del'){
    $id = filterstr($_GET['id']);
    $conn->query("delete from cate where id='$id'");
    if($conn->affected_rows>0){
        redirect(2,'cate_list.php','删除成功');
    }
    else{
        redirect(2,'cate_list.php','删除失败');
    }
}
?>
<!doctype html>
<html>

    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">作品管理</span></div>
        </div>

        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="cate_add.php"><i class="icon-font"></i>新增栏目</a>

                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>


                            <th>ID</th>
                            <th>栏目名称</th>



                            <th>操作</th>
                        </tr>
                        <tr>
                            <?php
                            $result = $conn->query("select * from cate");

                            while($row = $result->fetch_assoc()){
                            ?>


                            <td><?php echo $row['id'];?></td>
                            <td title="<?php echo $row['class_name']; ?>"><a target="_blank" href="article_edit.php?id=<?php echo $row['id'];?>" title="<?php echo $row['class_name']; ?>"><?php echo $row['class_name']; ?></a>
                            </td>


                            <td>
                                <a class="link-update" href="cate_edit.php?id=<?php echo $row['id'];?>">修改</a>
                                <a class="link-del" href="javascript:del(<?php echo $row['id'];?>);">删除</a>
                            </td>
                        </tr>
                        <?php }?>

                    </table>

                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
<script>
    function del(id){
        if(false==confirm("是否确定删除记录?")) return;
        location.href='?action=del&id='+id;

    }
</script>
</body>
</html>

admin/cate_add.php

<?php
include_once 'init.php';
include "head.php";
header("Content-type: text/html; charset=utf-8");
$title = filterstr($_POST['title']);


//echo $cateid;
//$sql="insert into article (title,content,author,keyword,catid,c_time) value ('$title','$content','$author','$keyword',$cateid,'$c_time')";
//echo $sql;
if($_POST['sub']) {
    $conn->query("insert into cate(class_name)value('$title')");

    if ($conn->affected_rows > 0) {
        redirect(2, 'cate_list.php', '添加成功');
    } else {
        redirect(2, 'cate_add.php', '添加失败');
    }
}
?>

<!doctype html>
<html>

    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/jscss/admin/design/">栏目管理</a><span class="crumb-step">&gt;</span><span>新增栏目</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody><tr>

                        </tr>
                            <tr>
                                <th><i class="require-red">*</i>栏目:</th>
                                <td>
                                    <input class="common-text required" id="title" name="title" size="50" value="" type="text">
                                </td>
                            </tr>

                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" name="sub" type="submit">
                                    <input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>

    <!--/main-->
</div>

</body>
</html>

cate_editor.php

<?php

include_once "head.php";
header("Content-type: text/html; charset=utf-8");
$id = filterstr($_GET['id']);
//$result = $conn->query("select * from cate where id = '$id'");
//$row =$result->fetch_assoc();
$title = filterstr($_POST['title']);



if($_POST['sub']){
    //echo "update article set title = '$title',content='$content',author='$author',keyword='$keyword',c_time=$c_time,catid=$catid where id='$id'";

    $conn->query("update cate set class_name = '$title' where id='$id'");

    if ($conn->affected_rows > 0) {
        redirect(2, 'cate_list.php', '编辑成功');
    } else {
        redirect(2, 'cate_edit.php', '编辑失败');
    }
}




//$sql="insert into article (title,content,author,keyword,catid,c_time) value ('$title','$content','$author','$keyword',$cateid,'$c_time')";



?>

<!doctype html>
<html>

    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/jscss/admin/design/">作品管理</a><span class="crumb-step">&gt;</span><span>编辑作品</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody><tr>


                        </tr>
                        <tr><?php
                            $row=$conn->query("select * from cate where id = '$id'" );
                            $row  = $row->fetch_assoc();

                            ?>
                            <th><i class="require-red">*</i>栏目:</th>
                            <td>
                                <input class="common-text required" id="title" name="title" value="<?php echo $row['class_name']; ?>" size="50"  type="text">
                            </td>
                        </tr>

                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary btn6 mr10" value="提交"  name ="sub" type="submit">
                                <input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">
                            </td>
                        </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>

    <!--/main-->
</div>

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值