add_news.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form action="insert.php" method="post">
请输入新闻的title:<input type="text" name="title" />
请选择新闻类型:<select name="c_id">
<option value="1">体育</option>
<option value="1">娱乐</option>
</select>
<br />
请输入新闻的content:<br />
<textarea cols="60" rows="15" name="content"></textarea>
<input type="submit" value="提交" />
</form>
</html>
</body>
admin.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>news后台管理</title>
</head>
<frameset rows="20%,*%">
<frame src="logo.php" />
<frameset cols="20%,*">
<frame src="menu.php" name="menu" />
<frame src="win.php" name="win" />
</frameset>
</frameset><noframes></noframes>
<body>
</body>
</html>
connectmysql.php
<?php
mysql_connect('localhost','root','123');
mysql_select_db('news');
mysql_query('set names utf8');
?>
index.php
<?php
include ('connectmysql.php');
include('../libs/Smarty.class.php');
$array_new = array();
$q = "select * from new order by news_date desc limit 5";
$result = mysql_query($q);
while($row = mysql_fetch_assoc($result))
{
$array_new[]=$row;
}
//var_dump($array_new);
$smarty=new Smarty();
$smarty->reInitSmarty("../demo/templates","../demo/templates_c","../demo/configs","../demo/cache");
$smarty->assign("array_new",$array_new);
$smarty->display('index1.tpl');
insert.php
<?php
include ('connectmysql.php');
$q="insert into new(title,content,news_date,news_cate_id) values('".$_POST['title']."','".$_POST['content']."',now(),'".$_POST['c_id']."')";
mysql_query($q);
if(mysql_affected_rows()>0) echo "新闻添加成功";
?>
logo.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>logo</title>
</head>
<body>
<center>
<h1 style="background-color:#F39">欢迎使用news后台管理系统</h1>
<a href="index.php">前台展示</a>
</center>
</body>
</html>
menu.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>menu</title>
</head>
<body>
<ul>
<li><a href="add_news.php" target="win">添加新闻</a></li>
<li><a href="update_news.php" target="win">修改新闻</a></li>
<li><a href="delete_news.php" target="win">删除新闻</a></li>
</ul>
</body>
</html>