简单的php留言本例子温习

WBOY
发布: 2016-07-28 08:29:11
原创
1059 人浏览过

首先写前端:写在10.html页面上

<code><span><span>html</span><span>xmlns</span>=<span>"http://www.w3.org/1999/xhtml"</span><span>lang</span>=<span>"zh-CN"</span>></span><span>head</span>><span>meta</span><span>http-equiv</span>=<span>"Content-Type"</span><span>content</span>=<span>"text/html; charset=UTF-8"</span>><span>title</span>>10<span><span>title</span>></span><span>meta</span><span>name</span>=<span>"description"</span><span>content</span>=<span>""</span> /><span><span>head</span>></span><span>body</span>><span>form</span><span>action</span>=<span>"10.php"</span><span>method</span>=<span>"post"</span>><span>input</span><span>type</span>=<span>"text"</span><span>name</span>=<span>"title"</span>/><span>input</span><span>type</span>=<span>"text"</span><span>name</span>=<span>"content"</span>/><span>input</span><span>type</span>=<span>"submit"</span> /><span><span>form</span>></span><span><span>body</span>></span><span><span>html</span>></span></code>
登录后复制

10.php 想txt文本中写入内容

<code><span><?php </span><span>$str</span>=<span>$_POST</span>[<span>'title'</span>].<span>','</span>.<span>$_POST</span>[<span>'content'</span>]. <span>"\n"</span>;

<span>$fh</span>=fopen(<span>'1.txt'</span>, <span>'a'</span>);

fwrite(<span>$fh</span>, <span>$str</span>);

fclose(<span>$fh</span>);

<span>echo</span><span>"ok"</span>;


 <span>?></span></span></code>
登录后复制

msg.php 留言本标题列表页

<code><span><span><?php </span>    header(<span>"Content-Type:text/html;charset=utf8"</span>);

    <span>$fh</span>=fopen(<span>'1.txt'</span>, <span>'r'</span>);

    <span>$i</span>=<span>1</span>;

    <span>while</span> ((<span>$str</span> = fgetcsv(<span>$fh</span>))!=<span>false</span>) {
        <span>echo</span><span>'<li><a href="msgtid.php?tid='</span>,<span>%24i</span>,<span>'">'</a></li></span>,<span>$str</span>[<span>0</span>],<span>''</span>;

        <span>$i</span>=<span>$i</span>+<span>1</span>;
    }

 <span>?></span></span></span></code>
登录后复制

redmsg.php 内容页

<code><span><span><span><?php </span>    header(<span>"Content-Type:text/html;charset=utf8"</span>);

    <span>$fh</span>=fopen(<span>'1.txt'</span>, <span>'r'</span>);

    <span>$i</span>=<span>1</span>;

    <span>while</span> ((<span>$str</span> = fgetcsv(<span>$fh</span>))!=<span>false</span>) {

        <span>if</span> (<span>$i</span>==<span>$_GET</span>[<span>'tid'</span>]) {
            <span>echo</span><span>'<li>'</li></span>,<span>$str</span>[<span>0</span>],<span>'<br>'</span>;

            <span>echo</span><span>'<li>'</li></span>,<span>$str</span>[<span>1</span>],<span>'<br>'</span>;
        }
    <span>$i</span>=<span>1</span>+<span>$i</span>;     
    }

 <span>?></span></span></span></span></code>
登录后复制
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了 简单的php留言本例子温习,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板