Php generates static html
Last Update:2014-05-15
Source: Internet
Author: User
& Lt ;? Phprequire & quot; comm. php & quot; if (isset ($ _ POST [& amp; #39; submit & amp; #39;]) {$ title $ _ POST [& amp; #39; title & amp; #39;]; $ content $ _ POST [& amp; #39; content & amp; #39 Require "comm. php ";
If (isset ($ _ POST ['submit ']) {
$ Title = $ _ POST ['title'];
$ Content = $ _ POST ['content'];
$ Addtime = time ();
$ SQL = "insert into news (title, content, addtime) values ('$ title',' $ content', '$ addtime ')";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
$ Time = date ('ymmd ');
$ Tmp = $ _ SERVER ['document _ root']. dirname ($ _ SERVER ['php _ SELF ']).'/'.20.time.20.title.'.'.html;
$ Fp = fopen ($ tmp, 'w ');
$ TmpT = $ _ SERVER ['document _ root']. dirname ($ _ SERVER ['php _ SELF ']).'/tmp.html ';
$ FpT = fopen ($ tmpT, 'r ');
$ Str = fread ($ fpT, filesize ($ tmpT ));
$ Str = str_replace ('{title}', $ title, $ str );
$ Str = str_replace ('{content}', $ content, $ str );
Fwrite ($ fp, $ str );
Fclose ($ fp );
Fclose ($ fpT );
Echo "OK ";
}
}
// ==========================================
Echo"
";
Echo $ _ SERVER ['document _ root'];
Echo"
";
Echo $ _ SERVER ['php _ SELF '];
Echo"
";
Echo date ('ymmd ');
Echo"
";
Echo dirname ($ _ SERVER ['php _ SELF ']);
?>
Require "comm. php ";
If (isset ($ _ POST ['submit ']) {
$ Title = $ _ POST ['title'];
$ Content = $ _ POST ['content'];
$ Addtime = time ();
$ SQL = "insert into news (title, content, addtime) values ('$ title',' $ content', '$ addtime ')";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
$ Time = date ('ymmd ');
$ Tmp = $ _ SERVER ['document _ root']. dirname ($ _ SERVER ['php _ SELF ']).'/'.20.time.20.title.'.'.html;
$ Fp = fopen ($ tmp, 'w ');
$ TmpT = $ _ SERVER ['document _ root']. dirname ($ _ SERVER ['php _ SELF ']).'/tmp.html ';
$ FpT = fopen ($ tmpT, 'r ');
$ Str = fread ($ fpT, filesize ($ tmpT ));
$ Str = str_replace ('{title}', $ title, $ str );
$ Str = str_replace ('{content}', $ content, $ str );
Fwrite ($ fp, $ str );
Fclose ($ fp );
Fclose ($ fpT );
Echo "OK ";
}
}
// ==========================================
Echo"
";
Echo $ _ SERVER ['document _ root'];
Echo"
";
Echo $ _ SERVER ['php _ SELF '];
Echo"
";
Echo date ('ymmd ');
Echo"
";
Echo dirname ($ _ SERVER ['php _ SELF ']);
?>
[Html] // tmp.html
{Title}
{Content}
From chaojie2009