简单的php留言本例子温习

WBOY
Lepaskan: 2016-07-28 08:29:11
asal
1058 orang telah melayarinya

首先写前端:写在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>
Salin selepas log masuk

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>
Salin selepas log masuk

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>
Salin selepas log masuk

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>
Salin selepas log masuk
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

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

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan