<?php
//处理用户的添加/更新/删除...请求
//先获取 oper值
$oper=$_POST['oper'];
if($oper==='add'){
//接收用户的新闻的各个信息
$title=$_POST['title'];
$content=$_POST['content'];
//把新闻添加到数据库
//这里大家可以使用工具类完成.
$con=mysql_connect("localhost","root","root");
if(!$con){
die("连接失败");
}
mysql_select_db("newssys",$con);
$sql="insert into news values(null,'$title','$content','')";
//echo $sql;
if(mysql_query($sql,$con)){
//生成静态文件.
$id=mysql_insert_id();
$html_filename='news-id'.$id.'.html';
//取出当前的年月日创建一个文件夹,把这个静态页面放入这个文件夹中.
$html_fp=fopen("../".$html_filename,'w');
//把模板文件读取.
$fp=fopen('news.tpl','r');
//循环读取
//如果没有读到文件的最后,就一直读取
while(!feof($fp)){
//一行行读.
$row=fgets($fp);
//把占位符替换掉->小函数 myreplace
//问题?
$row=str_replace('%title%',$title,$row);
$row=str_replace('%content%',$content,$row);
fwrite($html_fp,$row);
}
//关闭文件
fclose($html_fp);
fclose($fp);
echo "恭喜你,添加成功<a href='manage.html'>管理新闻</a>";
//怎样让首页面立即更新.
include "newsList.php";
}else{
die('添加失败');
}
}else if($oper==='update'){
}else if($oper==='delete'){
}
没有合适的资源?快使用搜索试试~ 我知道了~
页面静态化的正则表达式
共40个文件
html:18个
php:14个
htaccess:4个
需积分: 10 8 下载量 162 浏览量
2013-12-09
09:46:27
上传
评论
收藏 1.33MB RAR 举报
温馨提示
该文件包括了常用的页面静态化代码和正则表达式的使用方法,代码能够正常运行。
资源推荐
资源详情
资源评论
收起资源包目录
.rar (40个子文件)
课堂源码
static2
reg1.php 516B
index.php 72B
404 back.html 68B
.htaccess 1KB
404.html 68B
content.php 573B
aaa.html 186B
private
hsp.jpg 825KB
.htaccess 244B
aaa
.htaccess 15B
ttt.html 8B
abc.html 22B
controller
news.php 90B
public
.htaccess 16B
mygrass.jpg 271KB
cccddd.html 4B
mygrass.jpg 271KB
exam4.php 159B
newssys
manage
LoginAction.php 0B
manage.html 257B
newsAction.php 1KB
newsList.php 1KB
login.html 0B
addNews.html 679B
showNews.php 1KB
news.tpl 224B
news-id13.html 231B
news-id8.html 224B
index.html 1KB
news-id14.html 219B
news-id11.html 218B
news-id12.html 224B
news-id10.html 222B
news-id9.html 222B
test
aaa.html 186B
exam3.php 155B
ob2.php 349B
exam2.php 181B
ob1.php 591B
exam1.php 179B
共 40 条
- 1
资源评论
青蛙小王子
- 粉丝: 241
- 资源: 85
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功