Heim >Backend-Entwicklung >PHP-Tutorial >简单的php留言本例子温习

简单的php留言本例子温习

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-28 08:29:111089Durchsuche

首先写前端:写在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教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn