简易 文章发布系统——前台界面

2023-05-16

续  简易 文章发布系统——后台管理系统  
源自 慕课网 的学习
       关于简易文章发布系统——后台管理系统大致已经制作完毕,但是从安全方面来看,程序质量不高,只适合初学者进行学习开发,掌握php的开发流程和开发技巧,为以后引擎模板的学习打下基础。
       针对 后台管理系统,制作 简易文章发布系统的前台界面,用于用户的查看。
       使用同样的数据库和数据表,基于原来的目录结构进行设计:
       先来看下,前台文章展示的效果页:
       文章列表页 article.list.php
      样式 default.css
/*
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/

body {
	margin: 0;
	padding: 0;
	background: #FFFFFF;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 13px;
	color: #6D6D6D;
}

h1, h2, h3 {
	margin: 0;
	text-transform: lowercase;
	font-weight: normal;
	color: #78CC00;
}

h1 {
	letter-spacing: -1px;
	font-size: 32px;
}

h2 {
	font-size: 23px;
}

p, ul, ol {
	margin: 0 0 2em 0;
	text-align: justify;
	line-height: 26px;
}

a:link {
	color: #7AD000;
}

a:hover, a:active {
	text-decoration: none;
	color: #7AD000;
}

a:visited {
	color: #7AD000;
}

img {
	border: none;
}

img.left {
	float: left;
	margin: 7px 15px 0 0;
}

img.right {
	float: right;
	margin: 7px 0 0 15px;
}

/* Form */

form {
	margin: 0;
	padding: 0;
}

fieldset {
	margin: 0;
	padding: 0;
	border: none;
}

legend {
	display: none;
}

input, textarea, select {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-size: 13px;
	color: #333333;
}

#wrapper {
	background: #7ACF00 url(images/img03.jpg);
}

/* Header */

#header {
	width: 900px;
	height: 80px;
	margin: 0 auto 20px auto;
	padding-top: 10px;
}

#logo {
	float: left;
	height: 120px;
	margin-left: 30px;
}

#logo h1 {
	font-size: 38px;
	color: #3399CC;
}

#logo h1 sup {
	vertical-align: text-top;
	font-size: 24px;
}

#logo h1 a {
	color: #FFFFFF;
}

#logo h2 {
	text-transform: uppercase;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #FFFFFF;
}

#logo a {
	text-decoration: none;
	color: #FFFFFF;
}

/* Menu */

#menu {
	float: right;
}

#menu ul {
	margin: 0;
	padding: 28px 0 0 0;
	list-style: none;
}

#menu li {
	display: inline;
}

#menu a {
	display: block;
	float: left;
	margin-left: 5px;
	background: #6AB000;
	padding: 7px 10px;
	text-decoration: none;
	font-size: 15px;
	color: #FFFFFF;
}

#menu a:hover {
	text-decoration: underline;
}

#menu .active a {
}

/* Page */

#page {
	width: 900px;
	margin: 0 auto;
	padding: 20px 20px;
}

/* Content */

#content {
	float: left;
	width: 590px;
	padding: 0px 30px 0px 30px;
}

/* Post */

.post {
}

.post .title {
	margin-bottom: 20px;
	padding-bottom: 5px;
	border-bottom: 10px solid #EDEDED;
}

.post .entry {
}

.post .meta {
	margin: 0;
	padding: 0 0 60px 0;
	background: url(images/img04.jpg) repeat-x left 30%;
}

.post .meta p {
	margin: 0;
	line-height: normal;
}

.post .meta .byline {
	float: left;
	color: #0000FF;
}

.post .meta .links {
	float: left;
}

.post .meta .more {
	width: 185px;
	height: 35px;
	padding: 5px 0px 5px 0px;
	text-transform: uppercase;
	text-decoration: none;
	font-size: 11px;
}

.post .meta .comments {
	padding: 5px 0px 5px 0px;
	text-transform: uppercase;
	text-decoration: none;
	font-size: 11px;
}

.post .meta b {
	display: none;
}

/* Sidebar */

#sidebar {
	float: right;
	width: 230px;
}

#sidebar ul {
	margin: 0;
	padding: 10px 0 0 0;
	list-style: none;
}

#sidebar li {
	margin-bottom: 40px;
}

#sidebar li ul {
}

#sidebar li li {
	margin: 0;
	padding: 3px 0;
	border-bottom: 1px dashed #D1D1D1;
}

#sidebar li li a {
	margin: 0;
	padding-left: 25px;
	background: url(images/img01.png) no-repeat left 50%;
}

#sidebar h2 {
	margin-bottom: 10px;
	padding-bottom: 5px;
	border-bottom: 10px solid #EDEDED;
	font-size: 18px;
	font-weight: normal;
}

#sidebar a {
	text-decoration: none;
	color: #6D6D6D;
}

/* Search */

#search {
}

#search h2 {
	margin-bottom: 20px;
}

#s {
	width: 150px;
	margin-right: 5px;
	padding: 3px;
	border: 1px solid #F0F0F0;
}

#x {
	padding: 3px;
	background: #ECECEC url(images/img08.gif) repeat-x left bottom;
	border: none;
	text-transform: lowercase;
	font-size: 11px;
	color: #4F4F4F;
}

/* Boxes */

.box1 {
	padding: 20px;
	background: url(images/img05.gif) no-repeat;
}

.box2 {
	color: #BABABA;
}

.box2 h2 {
	margin-bottom: 15px;
	background: url(images/img10.gif) repeat-x left bottom;
	font-size: 16px;
	color: #FFFFFF;
}

.box2 ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.box2 a:link, .box2 a:hover, .box2 a:active, .box2 a:visited  {
	color: #EDEDED;
}

/* Footer */

#footer {
	height: 400px;
	min-height: 74px;
	padding: 10px 0 0 0;
	background: #979797 url(images/img02.jpg) repeat-x left top;
	font-family: Tahoma, Arial, Helvetica, sans-serif;
}

html>body #footer {
	height: auto;
}

#legal {
	clear: both;
	padding-top: 20px;
	text-align: center;
	text-transform: uppercase;
	font-size: 10px;
	color: #353535;
}

#legal a {
	font-weight: bold;
	color: #FFFFFF;
}

       通过对数据库info进行所有的文章显示即可, article.list.php如下:
<?php
	require_once('connect.php');
	$sql = "select * from article order by dateline desc";
	$query = mysql_query($sql);
	if($query && mysql_num_rows($query)) {
		while($row = mysql_fetch_assoc($query)) {
			$data[] = $row;
		}
	} else {
		$data = [];
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>文章发布系统</title>
	<meta name="keywords" content=""/>
	<meta name="description" content="文章发布系统"/>
	<link rel="stylesheet" href="default.css" type="text/css">
</head>
<body>
	<div id="wrapper">
		<div id="header">
			<div id="logo">
				<h1><a href="#">php与mysql<sup></sup></a></h1>
				<h2></h2>
			</div>

			<div id="menu">
				<ul>
					<li class="active"><a href="article.list.php">文章</a></li>
					<li><a href="about.php">关于我们</a></li>
					<li><a href="contact.php">联系我们</a></li>
				</ul>
			</div>
		</div>
	</div>

	<div id="page">
		<div id="content">
			<?php
				if(empty($data)) {
					echo "当前没有文章,请管理员在后台添加文章";
				} else {
					foreach ($data as $value) {
			?>
				
				<div class="post">
					<h1 class="title"><?php echo $value['title']; ?><span style="color:#CCC; font-size:14px;">  作者:<?php echo $value['author'];?></span></h1>
					<div class="entry">
						<?php echo $value['description']; ?>
					</div>
					<div class="meta">
						<p class="links"><a href="article.show.php?id=<?php echo $value['id']; ?>" class="more">查看详细</a>  »  </p>
					</div>
				</div>

			<?php
					}
				}
			?>
		</div>

		<div id="sidebar">
			<ul>
				<li id="search">
					<h2><b class="text1">Search</b></h2>
					<form action="article.search.php" method="get">
						<fieldset>
							<input type="text" id="s" name="key" value="">
							<input type="submit" id="x" value="Search">
						</fieldset>
					</form>
				</li>
			</ul>
		</div>

		<div style="clear: both;"> </div>
	</div>

	<div id="footer">
		<p id="legal">Copyright &copyright; 1995-2016, DreamBoy.NET, All Rights Reserved</p>
	</div>
</body>
</html>
       点击“查看详细”即可查看该篇文章的详细内容,通过传递对应文章的id到 article.show.php, article.show.php 查询该文章所有信息进行展示。
       article.show.php
<?php 
	require_once('connect.php');
	$id = intval($_GET['id']); // intval 转化为 整数,有非法字符会转化为0,防止sql注入
	$sql = "select * from article where id = $id";
	$query = mysql_query($sql);
	if($query && mysql_num_rows($query)) {
		$row = mysql_fetch_assoc($query);
	} else {
		echo "这篇文章不存在";
		exit;
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>文章详情页</title>
	<link rel="stylesheet" href="default.css" type="text/css">
</head>
<body>
	<div id="wrapper">
		<!-- start header -->
		<div id="header">
			<div id="logo">
				<h1><a href="#">php与mysql<sup></sup></a></h1>
				<h2></h2>
			</div>
			<div id="menu">
				<ul>
					<li class="active"><a href="article.list.php">文章</a></li>
					<li><a href="#">关于我们</a></li>
					<li><a href="#">联系我们</a></li>
				</ul>
			</div>
		</div>
		<!-- end header -->
	</div>

	<!-- start page -->
	<div id="page">
		<!-- start content -->
		<div id="content">
			<div class="post">
				<h1 class="title"><!--文章标题放置到这里--><?php echo $row['title']?><span style="color:#ccc;font-size:14px;">  作者:<!--作者放置到这里--><?php echo $row['author'];?></span></h1>
				<div class="entry">
					<!--文章内容放置到这里-->
					<?php echo $row['content']?>
				</div>
			</div>
		</div>
		<!-- end content -->
		<!-- start sidebar -->
		<div id="sidebar">
			<ul>
				<li id="search">
					<h2><b class="text1">Search</b></h2>
					<form method="get" action="article.search.php">
						<fieldset>
						<input type="text" id="s" name="key" value="" />
						<input type="submit" id="x" value="Search" />
						</fieldset>
					</form>
				</li>
			</ul>
		</div>
		<!-- end sidebar -->
		<div style="clear: both;"> </div>
	</div>
	<!-- end page -->
	<!-- start footer -->
	<div id="footer">
		<p id="legal"></p>
	</div>
	<!-- end footer -->
</body>
</html>

      如 点击查看一篇文章,结果如下:

       此外,在 article.list.php 即文章列表页,提供一个搜索功能,搜索含 关键字 的文章。点击“search”按钮,将要搜索的关键字发送给 article.search.php 进行搜索查找。
       article.search.php
<?php
	require_once('connect.php');
	$key = $_GET['key'];
	$sql = "select * from article where title like '%$key%' order by dateline desc";
	$query = mysql_query($sql);
	if($query && mysql_num_rows($query)) {
		while($row = mysql_fetch_assoc($query)) {
			$data[] = $row;
		}
	} else {
		$data = [];
	}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>文章发布系统</title>
	<meta name="keywords" content=""/>
	<meta name="description" content="文章发布系统"/>
	<link rel="stylesheet" href="default.css" type="text/css">
</head>
<body>
	<div id="wrapper">
		<div id="header">
			<div id="logo">
				<h1><a href="#">php与mysql<sup></sup></a></h1>
				<h2></h2>
			</div>

			<div id="menu">
				<ul>
					<li class="active"><a href="article.list.php">文章</a></li>
					<li><a href="about.php">关于我们</a></li>
					<li><a href="contact.php">联系我们</a></li>
				</ul>
			</div>
		</div>
	</div>

	<div id="page">
		<div id="content">
			<?php
				if(empty($data)) {
					echo "当前没有文章,请管理员在后台添加文章";
				} else {
					foreach ($data as $value) {
			?>
				
				<div class="post">
					<h1 class="title"><?php echo $value['title']; ?><span style="color:#CCC; font-size:14px;">  作者:<?php echo $value['author'];?></span></h1>
					<div class="entry">
						<?php echo $value['description']; ?>
					</div>
					<div class="meta">
						<p class="links"><a href="article.show.php?id=<?php echo $value['id']; ?>" class="more">查看详细</a>  »  </p>
					</div>
				</div>

			<?php
					}
				}
			?>
		</div>

		<div id="sidebar">
			<ul>
				<li id="search">
					<h2><b class="text1">Search</b></h2>
					<form action="article.search.php" method="get">
						<fieldset>
							<input type="text" id="s" name="key" value="">
							<input type="submit" id="x" value="Search">
						</fieldset>
					</form>
				</li>
			</ul>
		</div>

		<div style="clear: both;"> </div>
	</div>

	<div id="footer">
		<p id="legal">Copyright &copyright; 1995-2016, DreamBoy.NET, All Rights Reserved</p>
	</div>
</body>
</html>


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

简易 文章发布系统——前台界面 的相关文章

随机推荐

  • jQuery下的瀑布流效果

    使用jQuery制作瀑布流效果 xff0c 这里需要引入jQuery库 index html lt DOCTYPE html gt lt html lang 61 34 en 34 gt lt head gt lt meta charset
  • 使用js实现tab选项卡效果

    这里提供了一种制作选项卡的思路 在制作过程中首先考虑的是html结构 xff0c 元素如何摆放 xff0c 此外通过这样的摆放 xff0c 通过CSS样式是否可以达到我们所要的效果 最后通过js进行监听 xff0c 当进行选项卡切换时 xf
  • 使用js实现“别踩白块儿”游戏

    界面如下 xff1a 点击 开始游戏 xff0c 白格 将开始向下移动 xff0c 此后再每一行上开始出现一个 黑格 xff0c 对应列上按下对应的键即可消除黑格 xff0c 但不可跨行消除 xff08 即必须先消除 最近 一行上的 黑格
  • AJAX 跨域请求 - JSONP获取JSON数据

    转载自 xff1a 点击打开链接 Asynchronous JavaScript and XML Ajax 是驱动新一代 Web 站点 xff08 流行术语为 Web 2 0 站点 xff09 的关键技术 Ajax 允许在不干扰 Web 应
  • Ajax的实现和jQuery下的Ajax

    什么是Ajax呢 xff1f AJAX即 A synchronous J avascript A nd X ML xff08 异步JavaScript和XML xff09 xff0c 是指一种创建交互式网页应用的网页开发技术 AJAX 61
  • jQuery下的瀑布流效果(改)

    使用 window on 34 resize 34 waterfall 使得瀑布流列数可以动态变化 包含加载数据的模拟 useJQ html lt DOCTYPE html gt lt html lang 61 34 en 34 gt lt
  • 带有分散效果的瀑布流(jQuery实现)

    初始数据集中在窗口底部 xff0c 通过动画移动摆动到正确的位置 xff0c 同样模拟网络加载数据时 xff0c 图片也从窗口底部 动画 摆放到正确的位置 如下图所示 xff0c 这是初始数据移动的过程 移动结束后 xff0c 初始数据摆放
  • 使用jQuery、js实现必应搜索制作

    实现过程参考自 慕课网 xff0c 有关具体详情可参考视频 实现必应搜索制作 xff0c 结果如下 xff1a 点击提示框中的选项进行对应的跳转 xff08 在当前页面 xff09 xff1a 使用Ajax提交http请求 xff0c 从必
  • 网页在IE6下可能出现的小问题

    我们制作网页过程中 xff0c 需要对网页进行调试以兼容不同浏览器 这里使用IETester 针对网页在IE6进行调试 xff0c 解决一些可能出现的问题 1 在IE6可能会出现双边距 双边距出现的条件是当浮动元素的浮动方向和margin的
  • 雅虎WEB前端网站优化 -- 34条军规

    转载自 xff1a 点击打开链接 雅虎给出了优化网站加载速度的34条法则 xff08 包括Yslow规则22条 xff09 详细说明 xff0c 下载转发 ponytail 的译文 xff08 来自帕兰映像 xff09 1 Minimize
  • 91. Decode Ways(解码方法)

    这道题的关键在于推导出递推公式 xff0c 这里我将存储的数组定义为code xff0c 字符串为s xff0c code i 代表前i个字符可解码的数量 xff0c 即code i 代表的是s i 1 及之前字符的总解码数量 很明显可知c
  • PHP中的字符串定义——Heredoc结构形式

    在php中字符串类型可以用三种方法定义 xff1a 单引号形式 双引号形式和Heredoc结构形式 单引号形式和双引号的定义形式如下 xff1a lt php str string1 61 39 我是字符串 39 单引号 str strin
  • php get_magic_quotes_gpc()函数用法介绍

    转载自 xff1a 点击打开链接 magic quotes gpc函数在php中的作用是判断解析用户提示的数据 xff0c 如包括有 post get cookie过来的数据增加转义字符 xff0c 以确保这些数据不会引起程序 xff0c
  • PHP 单一入口

    转载自 xff1a 点击打开链接 单一入口概述 单一入口的应用程序就是说用一个文件处理所有的HTTP请求 xff0c 例如不管是列表页还是文章页 xff0c 都是从浏览器访问index php文件 xff0c 这个文件就是这个应用程序的单一
  • PHP下的MVC

    学习资源来自于慕课网 先来一个简单的Demo SimpleDemo 控制器C testController class php lt php class testController function show 控制器的作用是调用模型 xf
  • PHP操作mysql类的封装

    版本一 xff1a lt php 这是一个工具类 xff0c 作用是完成对数据库的操作 class SqlHelper public conn public dbname 61 34 test 34 public username 61 3
  • 简单新闻发布系统前台界面(html+css)

    运行效果如下 xff1a 图片素材 xff1a bg jpg header shadow png news icon png index html lt DOCTYPE html gt lt html lang 61 34 zh CN 34
  • 视图引擎Smarty的简单使用

    参考 xff1a http www jb51 net article 5091 htm 参考 xff1a http baike baidu com link url 61 FFySw2r dsE lTdQgGy2DpLhciXM JqUag
  • 简易 文章发布系统——后台管理系统

    来自于慕课网的学习 这里建立一个简易的文章发布系统 后台管理系统 xff0c 功能包括 文章的发表 查看文章列表 xff0c 其中还提供对文章的删除和修改功能 首先使用mysql建立数据库 info xff0c 在info数据库中建立一张
  • 简易 文章发布系统——前台界面

    续 简易 文章发布系统 后台管理系统 源自 慕课网 的学习 关于简易文章发布系统 后台管理系统大致已经制作完毕 xff0c 但是从安全方面来看 xff0c 程序质量不高 xff0c 只适合初学者进行学习开发 xff0c 掌握php的开发流程