php新闻管理系统(简单)学习教程

2023-10-31

最近因为工作原因需要使用php开发网页,所以开始学习php,在学习的过程中也遇到了很多困难,经过不断的查询百度各种学习资料,逐步的客服了这些困难和疑惑,现在我将学习过程中编写的代码分享给有需要的朋友,仅供参考。

此系统比较简单,共有20个php文件,3个文件夹(css,images,data),php文件分别为conn.php(数据库连接),index.php(首页),type.php(新闻分类页面),newscontent.php(最新新闻页面),admin_login.php(后台登录),chkadmin.php(登录判断),admin.php(后台中心),news_add.php(添加新闻),saveadd.php(添加新闻后台),news_upd.php(修改新闻),saveupdate.php(修改新闻后台),news_del.php(删除新闻),savedel.php(删除新闻后台),type_add.php(添加新闻分类),type_add_save.php(添加新闻分类后台),type_upd.php(修改新闻分类),type_upd_save.php(修改新闻分类后台),type_del.php(删除新闻分类),type_del_save.php(删除新闻分类后台),loginout(注销用户);css样式表2个style.css(前台页面样式),backstage.css(后台页面样式);images文件夹中一个banner文件,data中含有数据库导出文件。此项目源代码资源我已上传至(https://download.csdn.net/download/modern358/11074229),请自行查找下载。

1.conn.php(数据库连接)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/27
 */

$conn = mysqli_connect("localhost","root","","news");

@ mysqli_set_charset($conn,utf8);
@ mysqli_query($conn,utf8);

if(mysqli_connect_errno($conn))
{
    echo "数据库连接MySql连接失败".mysqli_connect_error()."<br>";
}

?>

2.index.php(首页)

<?php
    require_once('conn.php');
    $key_word = @ $_POST['key_word'];
?>
<html>
<head>
    <title>新闻管理系统</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div class="container">
        <div class="top_navigation">
            <span>PHP新闻管理系统</span>
            <ul>
                <li><a href="index.php">系统首页</a></li>
                <li><a href="newscontent.php">最新新闻</a></li>
                <li><a href="type.php">新闻分类</a></li>
                <li><a href="admin_login.php">后台管理</a></li>
            </ul>
        </div>
        <div class="top_banner">
            <img src="images/banner3.jpg" alt="banner">
        </div>
        <div class="content">
            <div class="content_left">
                <div class="news_type">
                    <p>新闻分类:</p>
                    <?php
                        /**
                         * Created by PhpStorm.
                         * User: jiawei
                         * Date: 2019/3/26
                         */

                        $sql2 = mysqli_query($conn,"SELECT * FROM newstype ORDER BY type_id ASC");
                        while ($info2 = mysqli_fetch_array($sql2))
                        {
                            $type_id = $info2['type_id'];
                            $type_name = $info2['type_name'];
                            echo "<span><a href='type.php?type_id=$type_id'>[$type_name]</a></span>";
                        }
                    ?>
                </div>
            </div>
            <div class="content_right">
                <form name="form1" method="post" action="index.php">
                    <span>查询主题:<input type="text" name="key_word" id="key_word" value="">
                    <input type="submit" name="news_query" id="news_query" value="查 询"></span>
                </form>

                <table class="news_list1">
                    <caption>最新新闻:</caption>
                    <tr>
                        <th class="tb_title">主 题</th>
                        <th class="tb_date">加入时间</th>
                        <th class="tb_detail">详细内容</th>
                    </tr>
                    <?php
                    $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                      WHERE news_title LIKE '%$key_word%'");
                    $info1 = mysqli_fetch_array($sql1);
                    $total = $info1['total'];
                    if($total == 0)
                    {
                        echo "本系统暂无任何查询数据。";
                        exit;
                    }
                    else
                    {
                        $page_size = 10;
                        if($total <= $page_size)
                        {
                            $page_connt = 1;
                        }
                        if(($total % $page_size) != 0)
                        {
                            $page_connt = intval($total/$page_size) + 1;
                        }
                        else
                        {
                            $page_connt = intval($total/$page_size);
                        }
                        if((@ $_GET['page']) == "")
                        {
                            $page = 1;
                        }
                        else
                        {
                            $page = intval($_GET['page']);
                        }
                        $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_title LIKE '%$key_word%' 
                          ORDER BY news_id ASC LIMIT "
                            .(($page-1)*$page_size).",$page_size");
                        while($info1 = mysqli_fetch_array($sql1))
                        {
                            $news_id = $info1['news_id'];
                            $news_title = $info1['news_title'];
                            $news_date = $info1['news_date'];
                            echo "<tr>";
                            echo "<td class='tb_l'>$news_title</td>";
                            echo "<td class='tb_c'>$news_date</td>";
                            echo "<td class='tb_c'><a href='newscontent.php?news_id=$news_id' title='$news_title'>查看</a></td>";
                            echo "</tr>";
                        }
                    }
                    ?>
                </table>
                <table class="page_list1">
                    <?php
                    echo "<tr>";
                    echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                    if($page >= 2)
                    {
                        echo "<a href='index.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='index.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                    }
                    if($page_connt >= 2)
                    {
                        for($i=1; $i<=$page_connt; $i++)
                        {
                            echo "<a href='index.php?page=$i'>&nbsp;$i&nbsp;</a>";
                        }
                    }
                    if($page >= 2)
                    {
                        echo "<a href='index.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                            "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='index.php?page=$page_connt' title='尾页'>尾页</a>";
                    }
                    echo "</td>";
                    echo "</tr>";
                    ?>

                </table>

            </div>
        </div>
        <div class="footer">
            <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
        </div>
    </div>
</body>
</html>

3.type.php(新闻分类页面)

<?php
require_once('conn.php');
?>
<html>
<head>
    <title>新闻分类</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
    <div class="top_navigation">
        <span>PHP新闻管理系统</span>
        <ul>
            <li><a href="index.php">系统首页</a></li>
            <li><a href="newscontent.php">最新新闻</a></li>
            <li><a href="type.php">新闻分类</a></li>
            <li><a href="admin_login.php">后台管理</a></li>
        </ul>
    </div>
    <div class="top_banner">
        <img src="images/banner3.jpg" alt="banner">
    </div>
    <div class="content">
        <div class="content_type">
            <table class="type_list1">
                <caption>分类新闻:</caption>
                <tr>
                    <th class="tb_title">主 题</th>
                    <th class="tb_date">加入时间</th>
                    <th class="tb_detail">详细内容</th>
                </tr>
                <?php
                /**
                 * Created by PhpStorm.
                 * User: jiawei
                 * Date: 2019/3/26
                 */
                if(empty($_GET['type_id']))
                {
                    $type_id = 1;
                }
                else
                {
                    $type_id = $_GET['type_id'];
                }
                $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                  WHERE news_type=$type_id");
                $info1 = mysqli_fetch_array($sql1);
                $total = $info1['total'];
                if($total == 0)
                {
                    echo "本系统暂无任何查询数据。";
                    exit;
                }
                else
                {
                    $page_size = 10;
                    if($total <= $page_size)
                    {
                        $page_connt = 1;
                    }
                    if(($total % $page_size) != 0)
                    {
                        $page_connt = intval($total/$page_size) + 1;
                    }
                    else
                    {
                        $page_connt = intval($total/$page_size);
                    }
                    if((@ $_GET['page']) == "")
                    {
                        $page = 1;
                    }
                    else
                    {
                        $page = intval($_GET['page']);
                    }
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_type='$type_id'  
                      ORDER BY news_id ASC LIMIT "
                        .(($page-1)*$page_size).",$page_size");
                    while($info1 = mysqli_fetch_array($sql1))
                    {
                        $news_id = $info1['news_id'];
                        $news_title = $info1['news_title'];
                        $news_date = $info1['news_date'];
                        echo "<tr>";
                        echo "<td class='tb_l'>[分类:$type_id] $news_title</td>";
                        echo "<td class='tb_c'>$news_date</td>";
                        echo "<td class='tb_c'><a href='newscontent.php?news_id=$news_id' title='$news_title'>查看</a></td>";
                        echo "</tr>";
                    }
                }
                ?>
            </table>
            <table class="page_list2">
                <?php
                echo "<tr>";
                echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                if($page >= 2)
                {
                    echo "<a href='type.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='type.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                }
                if($page_connt >= 2)
                {
                    for($i=1; $i<=$page_connt; $i++)
                    {
                        echo "<a href='type.php?page=$i'>&nbsp;$i&nbsp;</a>";
                    }
                }
                if($page >= 2)
                {
                    echo "<a href='type.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                        "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='type.php?page=$page_connt' title='尾页'>尾页</a>";
                }
                echo "</td>";
                echo "</tr>";
                ?>

            </table>

        </div>
    </div>
    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



4.newscontent.php(最新新闻页面)

<?php
require_once('conn.php');
?>
<html>
<head>
    <title>新闻内容</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
    <div class="top_navigation">
        <span>PHP新闻管理系统</span>
        <ul>
            <li><a href="index.php">系统首页</a></li>
            <li><a href="newscontent.php">最新新闻</a></li>
            <li><a href="type.php">新闻分类</a></li>
            <li><a href="admin_login.php">后台管理</a></li>
        </ul>
    </div>
    <div class="top_banner">
        <img src="images/banner3.jpg" alt="banner">
    </div>
    <div class="news_content">
        <div>
            <table class="news_content_list">
                <?php
                /**
                 * Created by PhpStorm.
                 * User: jiawei
                 * Date: 2019/3/26
                 */
                if(empty($_GET['news_id']))
                {
                    $sql1 = mysqli_query($conn,"SELECT news_id,news_title FROM news ORDER BY news_id DESC");
                    $info1 = mysqli_fetch_array($sql1);
                    $news_id = $info1['news_id'];
                }
                else
                {
                    $news_id = $_GET['news_id'];
                }
                $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                $info1 = mysqli_fetch_array($sql1);
                ?>
                <tr>
                    <th class="tb_title">新闻标题:&nbsp;&nbsp;<?php echo $info1['news_title']?></th>
                    <th class="tb_date">加入时间:&nbsp;&nbsp;<?php echo $info1['news_date']?>&nbsp;&nbsp;</th>
                </tr>
                <tr>
                    <td colspan="2" style="font-weight: bold">新闻内容:</td>
                </tr>
                <tr>
                    <td colspan="2" style="text-indent: 2em;line-height: 22px;"><?php echo $info1['news_content']?></td>
                </tr>
            </table>
        </div>
    </div>
    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



5.admin_login.php(后台登录)

<html>
<head>
    <title>后台登录</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body class="login_bk">
    <form name="form1" method="post" action="chkadmin.php">
        <div class="login_area">
            <table>
               <tr>

                   <td colspan="2"><strong>新闻管理系统后台登录</strong></td>
               </tr>
                <tr>
                    <td class="tb_l">用户:</td>
                    <td class="tb_r"><input type="text" name="user_name" id="user_name"></td>
                </tr>
                <tr>
                    <td class="tb_l">密码:</td>
                    <td class="tb_r"><input type="password" name="pwd" id="pwd"></td>
                </tr>
                <tr>

                    <td colspan="2"><input type="submit" name="button1" id="button1" value="提 交">
                    <input type="reset" name="button2" id="button2" value="重 置"></td>
                </tr>
            </table>
            <p><a href="index.php">返回首页</a></p><sapn>提示:用户 admin, 密码123 </sapn><span>  用户 root,密码 456 </span>
        </div>
    </form>
</body>
</html>

6.chkadmin.php(登录判断)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */
require_once('conn.php');
$user_name = $_POST['user_name'];
$pwd = $_POST['pwd'];

class chkinput
{
    var $name;
    var $password;

    function __construct($n,$p)
    {
        $this->name = $n;
        $this->password = $p;
    }

    function checkinput()
    {
        include('conn.php');
        $sql = mysqli_query($conn,"SELECT * FROM admin WHERE username='".$this->name."'");
        $info = mysqli_fetch_array($sql);
        if($info == false)
        {
            echo "<script>alert('用户名输入错误!');history.back();</script>";
            exit;
        }
        else
        {
            if($info['password']==$this->password)
            {
                session_start();
                $_SESSION['user_name'] = $info['username'];
                $_SESSION['id'] = $info['id'];
                header("location:admin.php");
                exit;
            }
            else
            {
                echo "<script>alert('密码输入不正确!');history.back();</script>";
                exit;
            }
        }

    }

}

$obj = new chkinput($user_name,$pwd);
$obj->checkinput();

7.admin.php(后台中心)

<?php
session_start();
require_once('conn.php');
$key_word = @ $_POST['key_word'];
?>
<html>
<head>
    <title>系统后台</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
            if(@ $_SESSION['user_name'] == "")
            {
                echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
                exit;
            }
            else
            {
                $user_name = $_SESSION['user_name'];
                echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <div class="content_left">
            <div class="news_type">
                <table>
                    <tr>
                        <th>新闻管理系统后台中心:</th>
                    </tr>
                    <tr>
                        <td><a href="news_add.php">添加新闻</a></td>
                    </tr>
                    <tr>
                        <td><a href="type_add.php">添加新闻分类</a></td>
                    </tr>
                    <tr>
                        <td>分类/管理</td>
                    </tr>
                    <?php
                    $sql2 = mysqli_query($conn,"SELECT * FROM newstype ORDER BY type_id ASC");
                    while ($info2 = mysqli_fetch_array($sql2))
                    {
                        $type_id = $info2['type_id'];
                        $type_name = $info2['type_name'];
                        echo "<tr>";
                        echo "<td>[$type_name]&nbsp;&nbsp;<a href='type_upd.php?type_id=$type_id'>修改</a>
                        &nbsp;&nbsp;<a href='type_del.php?type_id=$type_id'>删除</a></td>";
                        echo "</tr>";
                    }
                    ?>
                </table>

            </div>
        </div>
        <div class="content_right">
            <form name="form1" method="post" action="admin.php">
                    <span>查询主题:<input type="text" name="key_word" id="key_word" value="">
                    <input type="submit" name="news_query" id="news_query" value="查 询"></span>
            </form>

            <table class="news_list1">
                <caption>新闻列表:</caption>
                <tr>
                    <th class="tb_title">标 题</th>
                    <th class="tb_date">加入时间</th>
                    <th class="tb_detail">详细内容</th>
                </tr>
                <?php
                $sql1 = mysqli_query($conn,"SELECT COUNT(*) AS total FROM news
                      WHERE news_title LIKE '%$key_word%'");
                $info1 = mysqli_fetch_array($sql1);
                $total = $info1['total'];
                if($total == 0)
                {
                    echo "本系统暂无任何查询数据。";
                    exit;
                }
                else
                {
                    $page_size = 10;
                    if($total <= $page_size)
                    {
                        $page_connt = 1;
                    }
                    if(($total % $page_size) != 0)
                    {
                        $page_connt = intval($total/$page_size) + 1;
                    }
                    else
                    {
                        $page_connt = intval($total/$page_size);
                    }
                    if((@ $_GET['page']) == "")
                    {
                        $page = 1;
                    }
                    else
                    {
                        $page = intval($_GET['page']);
                    }
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_title LIKE '%$key_word%' 
                          ORDER BY news_id ASC LIMIT "
                        .(($page-1)*$page_size).",$page_size");
                    while($info1 = mysqli_fetch_array($sql1))
                    {
                        $news_id = $info1['news_id'];
                        $news_title = $info1['news_title'];
                        $news_date = $info1['news_date'];
                        echo "<tr>";
                        echo "<td class='tb_l'>$news_title</td>";
                        echo "<td class='tb_c'>$news_date</td>";
                        echo "<td class='tb_c'><a href='news_upd.php?news_id=$news_id'>修改</a>&nbsp;&nbsp;
                            <a href='news_del.php?news_id=$news_id'>删除</a></td>";
                        echo "</tr>";
                    }
                }
                ?>
            </table>
            <table class="page_list1">
                <?php
                echo "<tr>";
                echo "<td>共有数据&nbsp;$total&nbsp;条,每页显示&nbsp;$page_size&nbsp;条; 第&nbsp;$page&nbsp;页/共&nbsp;$page_connt&nbsp;页:&nbsp;";
                if($page >= 2)
                {
                    echo "<a href='admin.php?page=1' title='首页'>&nbsp;首&nbsp;&nbsp;页&nbsp;</a>/<a href='admin.php?page="
                        .($page-1)."' title='前一页'>前一页</a>&nbsp;&nbsp;";
                }
                if($page_connt >= 2)
                {
                    for($i=1; $i<=$page_connt; $i++)
                    {
                        echo "<a href='admin.php?page=$i'>&nbsp;$i&nbsp;</a>";
                    }
                }
                if($page >= 2)
                {
                    echo "<a href='admin.php?page=".(($page+1)>=$page_connt?$page_connt:($page+1)).
                        "' title='后一页'>&nbsp;&nbsp;后一页</a>/<a href='admin.php?page=$page_connt' title='尾页'>尾页</a>";
                }
                echo "</td>";
                echo "</tr>";
                ?>

            </table>

        </div>
    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>


8.news_add.php(添加新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>添加新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.news_title.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻标题!";
                form.news_title.style.backgroundColor = "red";
                form.news_title.select();
                return false;
            }
            if(form.news_author.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写作者!";
                form.news_author.style.backgroundColor = "red";
                form.news_author.select();
                return false;
            }
            if(form.news_content.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻内容!";
                form.news_content.style.backgroundColor = "red";
                form.news_content.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="saveadd.php" onsubmit="return chkinput(this)">
            <table class="newsadd_tb">
                <tr>
                    <td colspan="2"><strong>添加新闻:</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title">
                    <input type="hidden" name="news_date" id="news_date" value="<?php echo date("Y-m-d");?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type">
                        <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value='$type_id'>$type_name</option>";
                            }
                        ?>
                        </select>&nbsp;*&nbsp;&nbsp;作者:<input type="text" name="news_author" id="news_author"></td>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100"></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="添 加">
                    <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



9.saveadd.php(添加新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_title = $_POST['news_title'];
$news_type = $_POST['news_type'];
$news_author = $_POST['news_author'];
$news_content = $_POST['news_content'];
$news_date = $_POST['news_date'];

mysqli_query($conn,"INSERT INTO news(news_title,news_type,news_content,news_date,news_author)
  VALUES('$news_title',$news_type,'$news_content','$news_date','$news_author')");

echo "<script>alert('添加成功!');history.go(-1);</script>";

?>

10.news_upd.php(修改新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>修改新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.news_title.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻标题!";
                form.news_title.style.backgroundColor = "red";
                form.news_title.select();
                return false;
            }
            if(form.news_author.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写作者!";
                form.news_author.style.backgroundColor = "red";
                form.news_author.select();
                return false;
            }
            if(form.news_content.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写新闻内容!";
                form.news_content.style.backgroundColor = "red";
                form.news_content.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="saveupdate.php" onsubmit="return chkinput(this)">
            <table class="newsadd_tb">
                <?php
                    $news_id = $_GET['news_id'];
                    $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                    $info1 = mysqli_fetch_array($sql1);

                ?>
                <tr>
                    <td colspan="2"><strong>修改新闻:</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title" value="<?php echo $info1['news_title'];?>">
                        <input type="hidden" name="news_date" id="news_date" value="<?php echo date("Y-m-d");?>">
                    <input type="hidden" name="news_id" id="news_id" value="<?php echo $info1['news_id'];?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type" id="news_type">
                            <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value=$type_id>$type_name</option>";
                            }
                            ?>
                        </select>&nbsp;*&nbsp;&nbsp;
                        作者:<input type="text" name="news_author" id="news_author" value="<?php echo $info1['news_author'];?>"></td>
                        <?php
                        $t_id = $info1['news_type'];
                        $t_id -= 1; // selectedIndex是从0开始的,数据库ID是从1开始的,为了匹配需减去1.
                        echo "<script>document.getElementById('news_type').selectedIndex='$t_id';</script>";
                        ?>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100"><?php echo $info1['news_content'];?></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="修 改">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



11.saveupdate.php(修改新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_id = $_POST['news_id'];
$news_title = $_POST['news_title'];
$news_type = $_POST['news_type'];
$news_author = $_POST['news_author'];
$news_content = $_POST['news_content'];
$news_date = $_POST['news_date'];

mysqli_query($conn,"UPDATE news SET news_title='$news_title',news_type = '$news_type',news_content='$news_content',
news_date='$news_date',news_author='$news_author' WHERE news_id='$news_id'");

echo "<script>alert('修改成功!');history.go(-2);</script>";

?>

12.news_del.php(删除新闻)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>删除新闻</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">

</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="savedel.php">
            <table class="newsadd_tb">
                <?php
                $news_id = $_GET['news_id'];
                $sql1 = mysqli_query($conn,"SELECT * FROM news WHERE news_id=$news_id");
                $info1 = mysqli_fetch_array($sql1);

                ?>
                <tr>
                    <td colspan="2"><strong>删除新闻:您确认要删除此新闻吗?</strong></td>
                </tr>
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="news_title" id="news_title" disabled="disabled" value="<?php echo $info1['news_title'];?>">
                        <input type="hidden" name="news_date" id="news_date" disabled="disabled" value="<?php echo date("Y-m-d");?>">
                        <input type="hidden" name="news_id" id="news_id" value="<?php echo $info1['news_id'];?>"></td>
                </tr>
                <tr>
                    <td>新闻分类:</td>
                    <td><select name="news_type" id="news_type" disabled="disabled">
                            <?php
                            $sql = mysqli_query($conn,"SELECT * FROM newstype");
                            while($info = mysqli_fetch_array($sql))
                            {
                                $type_id = $info['type_id'];
                                $type_name = $info['type_name'];
                                echo "<option value=$type_id>$type_name</option>";
                            }
                            ?>
                        </select>&nbsp;*&nbsp;&nbsp;
                        作者:<input type="text" name="news_author" id="news_author" disabled="disabled" value="<?php echo $info1['news_author'];?>"></td>
                    <?php
                    $t_id = $info1['news_type'];
                    $t_id -= 1; // selectedIndex是从0开始的,数据库ID是从1开始的,为了匹配需减去1.
                    echo "<script>document.getElementById('news_type').selectedIndex='$t_id';</script>";
                    ?>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td><textarea name="news_content" rows="20" cols="100" disabled="disabled"><?php echo $info1['news_content'];?></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="删 除">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



13.savedel.php(删除新闻后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$news_id = $_POST['news_id'];
mysqli_query($conn,"DELETE FROM news WHERE news_id=$news_id");

echo "<script>alert('删除成功!');history.go(-2);</script>";

?>

14.type_add.php(添加新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>添加分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.type_name.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写分类名称!";
                form.type_name.style.backgroundColor = "red";
                form.type_name.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_add_save.php" onsubmit="return chkinput(this)">
            <table class="typeadd_tb">
                <tr>
                    <td colspan="2"><strong>添加新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="添 加">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



15.type_add_save.php(添加新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_name = $_POST['type_name'];
mysqli_query($conn,"INSERT INTO newstype(type_name) VALUES('$type_name')");

echo "<script>alert('添加成功!');history.back();</script>";

?>

16.type_upd.php(修改新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>修改分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
    <script type="text/javascript">
        function chkinput(form)
        {
            if(form.type_name.value == "")
            {
                document.getElementById('error_note').innerHTML = "错误提示:请填写分类名称!";
                form.type_name.style.backgroundColor = "red";
                form.type_name.select();
                return false;
            }
            return true;
        }
    </script>
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_upd_save.php" onsubmit="return chkinput(this)">
            <table class="typeadd_tb">
                <?php
                    $type_id = $_GET['type_id'];
                    $sql = mysqli_query($conn,"SELECT * FROM newstype WHERE type_id=$type_id");
                    $info = mysqli_fetch_array($sql);
                ?>
                <tr>
                    <td colspan="2"><strong>修改新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name" value="<?php echo $info['type_name'];?>">
                    <input type="hidden" name="type_id" id="type_id" value="<?php echo $info['type_id'];?>"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="修 改">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



17.type_upd_save.php(修改新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_id = $_POST['type_id'];
$type_name = $_POST['type_name'];

mysqli_query($conn,"UPDATE newstype SET type_name='$type_name' WHERE type_id='$type_id'");

echo "<script>alert('修改成功!');history.go(-2);</script>";

?>

18.type_del.php(删除新闻分类)

<?php
session_start();
require_once('conn.php');

?>
<html>
<head>
    <title>删除分类</title>
    <link type="text/css" rel="stylesheet" href="css/backstage.css">
</head>
<body>
<div class="container_bk">
    <div  class="top_navigation">
        <?php
        if(@ $_SESSION['user_name'] == "")
        {
            echo "<script>alert('您还没有登录,请先登录!');history.back();</script>";
            exit;
        }
        else
        {
            $user_name = $_SESSION['user_name'];
            echo "<span>管理员:[$user_name] 欢迎您!&nbsp;&nbsp;<a href='loginout.php'>注销用户</a></span>";
            echo "<span>&nbsp;&nbsp;<a href='admin.php'>后台首页</a>&nbsp;&nbsp;</span>";
        }
        ?>
    </div>
    <div class="top_banner">
        <span>新闻管理系统后台</span>
    </div>
    <div class="content_bk">
        <form name="form1" method="post" action="type_del_save.php">
            <table class="typeadd_tb">
                <?php
                $type_id = $_GET['type_id'];
                $sql = mysqli_query($conn,"SELECT * FROM newstype WHERE type_id=$type_id");
                $info = mysqli_fetch_array($sql);
                ?>
                <tr>
                    <td colspan="2"><strong>删除新闻分类:</strong></td>
                </tr>
                <tr>
                    <td class="tb_l">新闻分类名称:</td>
                    <td><input type="text" name="type_name" id="type_name" disabled="disabled" value="<?php echo $info['type_name'];?>">
                        <input type="hidden" name="type_id" id="type_id" value="<?php echo $info['type_id'];?>"></td>
                </tr>
                <tr>
                    <td class="tb_l">&nbsp;</td>
                    <td><input type="submit" name="button1" id="button1" value="删 除">
                        <input type="reset" name="button2" id="button2"><span id="error_note">&nbsp;</span></td>

                </tr>
            </table>
        </form>

    </div>

    <div class="footer">
        <p>新闻管理系统由modern358@163.com提供,仅供学习,不得用于商业行为,版权所有,违者必究。</p>
    </div>
</div>
</body>
</html>



19.type_del_save.php(删除新闻分类后台)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/26
 */

include('conn.php');

$type_id = $_POST['type_id'];

mysqli_query($conn,"DELETE FROM newstype WHERE type_id='$type_id'");

echo "<script>alert('删除成功!');history.go(-2);</script>";
?>

20.loginout(注销用户)

<?php
/**
 * Created by PhpStorm.
 * User: jiawei
 * Date: 2019/3/30
 */

session_start();
session_destroy();
header("location:index.php");
exit;

?>

21.style.css(前台页面样式),

html *,div
{
    margin: 0;
    padding: 0;
}

body
{
    font-size: 14px;
    background-color: #eeeeee;
}

/*----首页设置----------------------------------------------------------------------*/

.container
{
    width: 1060px;
    height: 100%;
    text-align: center;
    margin: 5px auto;
}

.container .top_navigation
{
    width: 100%;
    height: 50px;
    background-color: #e6a721;
    border-radius: 15px 0 0 0;
}

.container .top_navigation span
{
    float: left;
    display: inline-block;
    width: 300px;
    height: 48px;
    font-size: 30px;
    color: #333333;
    font-family: "楷体",Arial,"Arial Black";
    line-height: 48px;
    letter-spacing: 3px;
    text-shadow: 3px 3px 1px #999999;
    margin-right: 30px;
}

.container .top_navigation ul
{
    float: left;
    width: 730px;
    list-style: none;
}

.container .top_navigation ul li
{
    display: inline;
    float: left;
    height: 48px;
    line-height: 48px;
    width: 25%;
    font-size: 22px;

}

.container .top_navigation li a
{
    display: inline-block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    background-color: #e6a721;
    color: #333333;
    line-height: 48px;
}

.container .top_navigation li a:hover
{
    background-color: #e6c050;
    color: #ffffff;
}

.container .top_banner
{
    width: 100%;
    float: left;
    height:400px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: 3px 5px 8px #2d2d2d;
}

.container .top_banner img
{
    width: 100%;
    height: 100%;
    border: 1px solid #8294bd;
}

/*------首页内容--------------------------------------------------------------------------*/

.container .content
{
    width: 100%;
    height: 460px;
    float: left;
}

.container .content_left
{
    width: 260px;
    height: auto;
    float: left;
}

.container .content_left .news_type
{
    width: 100%;
    height: auto;
    text-align: left;
    padding-top: 10px;
    padding-left: 30px;
    font-size: medium;
}

.container .news_type p
{
    font-style: oblique;
    font-weight: bold;
    color: #2d2d2d;
}

.container .news_type span
{
    display: block;
    margin-left: 20px;
    margin-bottom: 8px;
    margin-top: 5px;
}

.container .news_type span a
{
    text-decoration: none;
    color: #2d2d2d;
}

/*---------首页右侧----------------------------------------------------------------------------*/
.container .content_right
{
    width: 780px;
    height: auto;
    float: right;
}

.container .content_right span
{
    font-size: 16px;
    margin-bottom: 10px;
}

.container .content_right span input[type=text]
{
    width: 200px;
    height: 28px;
    line-height: 28px;
}

.container .content_right span input[type=submit]
{
    width: 80px;
    height: 28px;
    line-height: 28px;
    border: 1px solid #237a47;
}


/*---------首页新闻列表-------------------------------------------------------------------------*/

.container .news_list1
{
    width: 700px;
    height: auto;
    color: #333333;
    margin: 10px auto;
    border: 1px solid #2d2d2d;
    border-collapse: collapse;
}

.container .news_list1 caption
{
    padding: 8px 20px;
    text-align: left;
    color: #ffffff;
    background-color: #555555;
}

.container .news_list1 th,.news_list1 td
{
    border: 1px solid #2d2d2d;
    height: 30px;

}

.container .news_list1 .tb_title
{
    width: 50%;
}

.container .news_list1 .tb_date
{
    width: 30%;
}

.container .news_list1 .tb_detail
{
    width: 20%;
}

.container .news_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container .news_list1 .tb_c
{
    text-align: center;
}

.container .page_list1
{
    width: 700px;
    height: auto;
    color: #2d2d2d;
    margin: 3px auto;
    border-bottom: 1px solid #2d2d2d;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container .page_list1 tr
{
    height: 40px;
}
/*-------首页底部----------------------------------------------------*/

.container .footer
{
    width: 100%;
    float: left;
    height: 50px;
    font-size: 16px;
    font-family: "微软雅黑";
    font-style: oblique;
    line-height: 50px;
    color: #ffffff;
    background-color: #e6a721;
}


/*------新闻分类-------------------------------------------------------------*/
.container .content_type
{
    width: 100%;
    height: 100%;
    float: left;

}

.container .type_list1
{
    width: 99%;
    text-align: center;
    margin: 0 auto;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    border-collapse: collapse;
}

.container .type_list1 caption
{
    text-align: left;
    margin-bottom: 15px;
    font-size: 18px;
    text-indent: 15px;
}

.container .type_list1 th,.type_list1 td
{
    height: 30px;
}

.container .type_list1 th
{
    border-bottom: 1px solid black;
    background-color: #555555;
}
.container .type_list1 td
{
    border-bottom: 1px dashed black;
}

.container .type_list1 .tb_title
{
    width: 60%;
}

.container .type_list1 .tb_date
{
    width: 15%;
}

.container .type_list1 .tb_detail
{
    width: 25%;
}

.container .type_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container .type_list1 .tb_c
{
    text-align: center;
}

.container .page_list2
{
    width: 99%;
    height: auto;
    color: #2d2d2d;
    margin: 10px auto;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container .page_list2 tr
{
    height: 40px;
}


/*-------新闻内容---------------------------------------------------------*/
.container .news_content
{
    width: 100%;
    height: auto;
    float: left;
    min-height: 400px;
    background-color: #ffffff;
}

.container .news_content_list
{
    width: 90%;
    height: auto;
    text-align: left;
    color: #444444;
    margin: 0 auto;
    border-left: 1px dashed #999999;
    border-right: 1px dashed #999999;
    padding: 2px 30px;

}

.container .news_content_list th
{
    height: 35px;
}

.container .news_content_list .tb_title
{
    width: 50%;
}

.container .news_content_list .tb_date
{
    width: 50%;
    text-align: right;
}

22.backstage.css(后台页面样式)

html *,div
{
    margin: 0;
    padding: 0;
}

body
{
    font-size: 14px;
    background-color: #eeeeee;
}

/*------后台登录-----------------------------------------------------------*/
.login_bk
{
    background-color: #cccccc;
}

.login_area
{
    width: 400px;
    height: 160px;
    border: 1px solid #555555;
    margin: 50px auto;
    background-color: #999999;
}

.login_area table
{
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 16px;

}

.login_area .tb_l
{
    width: 35%;
    text-align: right;
}

.login_area .tb_r
{
    width: 75%;
    text-align: left;
}

.login_area input[type=text],.login_area input[type=password]
{
    width: 200px;
    height: 25px;
    line-height: 25px;
}

.login_area input[type=submit],.login_area input[type=reset]
{
    width: 80px;
    height: 30px;
    border: 1px solid green;
    margin-left: 10px;
}

/*--------后台管理---------------------------------------------------------------------*/
.container_bk
{
    width: 1060px;
    height: 100%;
    text-align: center;
    margin: 5px auto;
}

.container_bk .top_navigation
{
    width: 100%;
    height:30px;
    float: left;
    text-align: right;
}

.container_bk .top_banner
{
    width: 100%;
    float: left;
    height:100px;
    margin-bottom: 15px;
    background-color: #e6a721;
}

.container_bk .top_banner span
{
    font-size: 28px;
    font-weight: bold;
    line-height: 100px;
    color: #ffffff;
    font-style: oblique;
    letter-spacing: 20px;
}

/*-----------------------------------------------------------------------------------*/
.container_bk .content_bk
{
    width: 100%;
    height: 460px;
    float: left;

}

.container_bk .content_left
{
    width: 260px;
    height: auto;
    float: left;
}

.container_bk .content_left .news_type
{
    width: 100%;
    height: auto;
    text-align: left;
    font-size: medium;
}

.container_bk .news_type table
{
    width: 100%;
    height: auto;
    text-align: left;
    border-collapse: collapse;
}

.container_bk .news_type th,.container_bk .news_type td
{
    height: 28px;
    line-height: 28px;
    text-indent: 5px;
}





/*---------------------------------------------------------------------*/
.container_bk .content_right
{
    width: 780px;
    height: auto;
    float: right;
}

.container_bk .content_right span
{
    font-size: 16px;
    margin-bottom: 10px;
}

.container_bk .content_right span input[type=text]
{
    width: 200px;
    height: 28px;
    line-height: 28px;
}

.container_bk .content_right span input[type=submit]
{
    width: 80px;
    height: 28px;
    line-height: 28px;
    border: 1px solid #237a47;
}

/*------------------------------------------------------------------------------*/

.container_bk .news_list1
{
    width: 700px;
    height: auto;
    color: #333333;
    margin: 10px auto;
    border: 1px solid #2d2d2d;
    border-collapse: collapse;
}

.container_bk .news_list1 caption
{
    padding: 8px 20px;
    text-align: left;
    color: #ffffff;
    background-color: #555555;
}

.container_bk .news_list1 th,.news_list1 td
{
    border: 1px solid #2d2d2d;
    height: 30px;

}

.container_bk .news_list1 .tb_title
{
    width: 50%;
}

.container_bk .news_list1 .tb_date
{
    width: 20%;
}

.container_bk .news_list1 .tb_detail
{
    width: 30%;
}

.container_bk .news_list1 .tb_l
{
    text-align: left;
    text-indent: 10px;
}

.container_bk .news_list1 .tb_c
{
    text-align: center;
}

.container_bk .page_list1
{
    width: 700px;
    height: auto;
    color: #2d2d2d;
    margin: 3px auto;
    border-bottom: 1px solid #2d2d2d;
    padding-bottom: 5px;
    border-collapse: collapse;
}

.container_bk .page_list1 tr
{
    height: 40px;
}


/*-------------------------------------------------------------------------------*/

.container_bk .footer
{
    width: 100%;
    float: left;
    height: 50px;
    font-size: 16px;
    font-family: "微软雅黑";
    font-style: oblique;
    line-height: 50px;
    color: #ffffff;
    background-color: #e6a721;
}

/*--------添加新闻--------------------------------------------------------------------*/
.container_bk .content_bk .newsadd_tb
{
    width: 100%;
    border-collapse: collapse;
}

.container_bk .newsadd_tb td
{
    height: 35px;
    line-height: 35px;
}

.container_bk .newsadd_tb input[name=news_title]
{
    width: 450px;
    height: 28px;
}

.container_bk .newsadd_tb input[name=news_author]
{
    width: 250px;
    height: 26px;
}

.container_bk .newsadd_tb select
{
    width: 150px;
    height: 26px;
}

.container_bk .newsadd_tb input[type=submit],.container_bk .newsadd_tb input[type=reset]
{
    width: 80px;
    height: 28px;
    border: 1px solid green;
    margin-top: 10px;
    margin-right: 20px;
}

/*--------------------------------------------------------------------*/
.container_bk .content_bk .typeadd_tb
{
    width: 100%;
    border-collapse: collapse;
}

.container_bk .typeadd_tb td
{
    height: 35px;
    line-height: 35px;
}

.container_bk .typeadd_tb input[name=type_name]
{
    width: 300px;
    height: 28px;
}

.container_bk .typeadd_tb input[type=submit],.container_bk .typeadd_tb input[type=reset]
{
    width: 80px;
    height: 28px;
    border: 1px solid green;
    margin-top: 10px;
    margin-right: 20px;
}

.container_bk .typeadd_tb .tb_l
{
    width: 15%;

}

/*---------------------------------------------------------------*/

.container_bk .news_type a
{
    text-decoration: none;
    color: #2d2d2d;
}

.container_bk .news_list1 a
{
    text-decoration: none;
    color: #2d2d2d;
}

23.数据库文件

-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- 主机: 127.0.0.1
-- 生成日期: 2019-03-30  
-- 服务器版本: 10.1.37-MariaDB
-- PHP 版本: 7.3.1

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- 数据库: `news`
--
CREATE DATABASE IF NOT EXISTS `news` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `news`;

-- --------------------------------------------------------

--
-- 表的结构 `admin`
--
-- 创建时间: 2019-03-26 09:43:13
--

CREATE TABLE `admin` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `admin`
--

INSERT INTO `admin` (`id`, `username`, `password`) VALUES
(1, 'admin', '123'),
(2, 'root', '456');

-- --------------------------------------------------------

--
-- 表的结构 `news`
--
-- 创建时间: 2019-03-26 09:39:24
--

CREATE TABLE `news` (
  `news_id` int(20) NOT NULL,
  `news_title` varchar(50) NOT NULL,
  `news_type` varchar(20) NOT NULL,
  `news_content` text,
  `news_date` date NOT NULL,
  `news_author` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `news`
--

INSERT INTO `news` (`news_id`, `news_title`, `news_type`, `news_content`, `news_date`, `news_author`) VALUES
(1, '新闻题目一', '1', '新闻内容一\r\n', '2019-03-27', '作者'),
(2, '新闻二', '1', '新闻内容二\r\n', '2019-03-27', '作者'),
(3, '新闻三', '1', '新闻内容三', '2019-03-27', '作者'),
(4, '新闻四', '1', '新闻内容四', '2019-03-30', '作者'),
(5, '新闻五', '1', '新闻内容五', '2019-03-27', '作者'),
(6, '新闻六', '1', '新闻内容六', '2019-03-27', '作者'),
(7, '新闻七', '1', '新闻内容七', '2019-03-27', '作者'),
(8, '新闻八', '1', '新闻内容八', '2019-03-27', '作者'),
(9, '新闻九', '1', '新闻内容九', '2019-03-29', '作者'),
(10, '新闻十', '1', '新闻内容十', '2019-03-27', '作者'),
(11, '新闻十一', '1', '新闻内容十一', '2019-03-30', '作者');

-- --------------------------------------------------------

--
-- 表的结构 `newstype`
--
-- 创建时间: 2019-03-26 09:41:25
--

CREATE TABLE `newstype` (
  `type_id` int(11) NOT NULL,
  `type_name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `newstype`
--

INSERT INTO `newstype` (`type_id`, `type_name`) VALUES
(1, '国内新闻'),
(2, '国际新闻');

--
-- 转储表的索引
--

--
-- 表的索引 `admin`
--
ALTER TABLE `admin`
  ADD PRIMARY KEY (`id`);

--
-- 表的索引 `news`
--
ALTER TABLE `news`
  ADD PRIMARY KEY (`news_id`);

--
-- 表的索引 `newstype`
--
ALTER TABLE `newstype`
  ADD PRIMARY KEY (`type_id`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `admin`
--
ALTER TABLE `admin`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- 使用表AUTO_INCREMENT `news`
--
ALTER TABLE `news`
  MODIFY `news_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;

--
-- 使用表AUTO_INCREMENT `newstype`
--
ALTER TABLE `newstype`
  MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

此数据库文件,有用的部分也就CREATE DATABASE news和CREATE TABLE admin,news,newstype以及INSERT INTO admin,news,newstype。

附带一张banner图片

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

php新闻管理系统(简单)学习教程 的相关文章

随机推荐

  • 树莓派3 有线静态路由设置_配置树莓派为wifi热点(AP模式)

    该功能主要用于搭建一个小型的的网络 使得连接至热点的各个设备可以进行通信 用于构建物联网系统 如智能家居 或是无线控制指定设备 另外这一网络也是独立的 并未启用NAT连接至互联网 具有一定的安全性也为研究提供了一定的便利 目前已经有很多方案
  • 删除rabbitmq的队列和队列中的数据

    欢迎访问本人博客查看原文 http wangnan tech 访问http rabbitmq安装IP 15672 帐号guest 密码guest 也可以使用自己创建的帐号 登录后访问http rabbitmq安装IP 15672 queue
  • Error:() java: 程序包org.springframework.beans.factory.annotation不存在

    写在前面 很重要 idea的2019 2020版本确实是存在很多bug的 我也踩过几个坑 我推荐使用idea2018 1 8版本 这个版本比较稳定 我暂时没遇到什么bug 其实遇到这个bug我很高兴 因为之前就出现过这个bug 当时公司前辈
  • 华为30道Python面试题总结

    Python是目前编程领域最受欢迎的语言 在本文中 我将总结华为 阿里巴巴等互联网公司Python面试中最常见的30个问题 每道题都提供参考答案 希望能够帮助你在求职面试中脱颖而出 找到一份高薪工作 这些面试题涉及Python基础知识 Py
  • hutool json转map_记一个Jackson与Hutool混用的坑

    技术公众号 Java In Mind Java In Mind 欢迎关注 问题出现 最近遇到一个问题 Hutool从4 1 7升级到4 6 8之后 使用feign调用出现错误 Caused by feign codec EncodeExce
  • CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory

    刚开始接触cxf 照着网上的例子写了一个demo 在测试 编写客户端访问服务运行的时候后台报了 CXF java lang RuntimeException Cannot create a secure XMLInputFactory 的错
  • Android gradle配置抽取合并

    一 为什么要合并 当项目中model或library变多过后 比如用到组件化或者引入第三方库需要配置多个build gradle文件 一旦需要统一其SDK或者其他组件版本就需要同时修改多个文件 这确实很麻烦 所以抽取gradle配置非常有必
  • JAVA单元测试框架-9-testng.xml管理依赖

    在testng xml里配置依赖管理 先写个测试用例 Test description 测试分组 groups operation public void TestGroupAdd System out print String value
  • 对七牛云的简单了解

    一 初识七牛云 1 概述 七牛云是国内领先的企业级公有云服务商 致力于打造以数据为核心的场景化PaaS服务 围绕富媒体场景 七牛先后推出了对象存储 融合CDN加速 数据通用处理 内容反垃圾服务 以及直播云服务等 通俗来讲七牛云就是一个服务器
  • UE4基础学习笔记——— 材质编辑器04

    材质实例 原理 不用在原父级材质编辑器中去调节材质 我们把重要的调节值设置为 转换为参数 将材质实例化 要修改只要修改参数即可 选择父级材质右键 创建材质实例 注意标识颜色是 深绿 在实例编辑界面中 出现了之前设置的可变参数 材质实例化方便
  • 《Java Web程序设计——开发环境的搭建》

    Java Web程序设计 开发环境的搭建 一 前言 这里主要分享一下我搭建开发环境的过程以及遇到的问题 其中涉及到的软件都可以从官网获取 若官方访问过慢也可到镜像网站或者下面分享的网盘链接中下载 软件安装路径尽量不要有中文 否则可能会报错
  • 试题 算法训练 拿金币-蓝桥杯

    这里的关键字仍然是动态规划 动态规划核心 拆分子 记住过往 减少重复计算 计算结果 1 不难发现 对于某个确定的路径上的特定位置上的金币总数 总是由该位置的上方的值或左边的值确定的 所以遍历数组位置的上方和左边的 再 比较 递加 就能计算出
  • K8S之资源管理

    文章目录 一 K8S中的资源 二 YAML语言 三 资源管理方式 一 命令式对象管理 二 命令式对象配置 三 声明式对象配置 一 K8S中的资源 在kuberbnetes中 所有的内容都抽象为资源 用户需要通过操作资源来管理kubernet
  • 可视化埋点方案和实践-PC-WEB端(一)

    目录 一 什么是可视化埋点 1 圈选 点选 即标记页面元素 的逻辑代码 2 捕获监听标记的元素的逻辑代码 二 遇到的坑 1 标记元素兼容性难 2 监听难 三 优点 1 方便了测试人员和运营人员 2 埋点的变更是即时的 不需要更新系统代码 3
  • 【Graph Neural Network】 GraphSAGE 基本原理与tensorflow2.0实现

    文章目录 GraphSAGE 前向传播算法 采样算法 聚合 aggragator 操作 参数学习 基于tensorflow2 0实现Graph SAGE GCN是一种利用图结构和邻居顶点属性信息学习顶点Embedding表示的方法 GCN是
  • 如何有效预防脱库

    本篇不从DBA 网络架构层面来讲述数据安全 这部分有很专业的架构和云上产品来解决 本篇重点从开发人员角度讲述如何避免数据安全的漏洞 相信大部分人都看到过这样的新闻 某某论坛泄漏了用户密码 某某物流公司泄漏了用户的手机号等等 我一直坚信大部分
  • 用Unity3D和VuforiaSDK简单做AR应用(入门)

    最近刚开始接触AR技术 结合u3d 算是对增强现实应用入个门 网上的例子不胜枚举 但有些浅尝辄止 根据自己几天来的摸索 毕竟新的技术源自国外 翻起晦涩的外文 一步一个脚印终于爬了出来 先上个史记效果图先 我取名之 鹿君下山 接下来说说步骤
  • Linux分区记录

    命令 cat proc mtd dev size erasesize name mtd0 00007000 00010000 vendor mtd1 00030000 00010000 IDBlock mtd2 00600000 00010
  • 3.5设计模式——————接口隔离原则——面向对象设计原则

    接口隔离原则的定义 接口隔离原则 Interface Segregation Principle ISP 要求程序员尽量将臃肿庞大的接口拆分成更小的和更具体的接口 让接口中只包含客户感兴趣的方法 2002 年罗伯特 C 马丁给 接口隔离原则
  • php新闻管理系统(简单)学习教程

    最近因为工作原因需要使用php开发网页 所以开始学习php 在学习的过程中也遇到了很多困难 经过不断的查询百度各种学习资料 逐步的客服了这些困难和疑惑 现在我将学习过程中编写的代码分享给有需要的朋友 仅供参考 此系统比较简单 共有20个ph