Simple PHP guestbook example review

WBOY
Release: 2016-07-28 08:29:11
Original
1062 people have browsed it

First write the front end: write on the 10.html page

<code><span><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span><span><<span>html</span><span>xmlns</span>=<span>"http://www.w3.org/1999/xhtml"</span><span>lang</span>=<span>"zh-CN"</span>></span><span><<span>head</span>></span><span><<span>meta</span><span>http-equiv</span>=<span>"Content-Type"</span><span>content</span>=<span>"text/html; charset=UTF-8"</span>></span><span><<span>title</span>></span>10<span></<span>title</span>></span><span><<span>meta</span><span>name</span>=<span>"description"</span><span>content</span>=<span>""</span> /></span><span></<span>head</span>></span><span><<span>body</span>></span><span><<span>form</span><span>action</span>=<span>"10.php"</span><span>method</span>=<span>"post"</span>></span><span><<span>input</span><span>type</span>=<span>"text"</span><span>name</span>=<span>"title"</span>/></span><span><<span>input</span><span>type</span>=<span>"text"</span><span>name</span>=<span>"content"</span>/></span><span><<span>input</span><span>type</span>=<span>"submit"</span> /></span><span></<span>form</span>></span><span></<span>body</span>></span><span></<span>html</span>></span></code>
Copy after login

10.php and want to write content in the txt text

<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></code>
Copy after login

msg.php Guestbook title list page

<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>$i</span>,<span>'">'</span>,<span>$str</span>[<span>0</span>],<span>'</a></li>'</span>;

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

 <span>?></span></span></code>
Copy after login

redmsg.php content page

<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>'</span>,<span>$str</span>[<span>0</span>],<span>'</li><br/>'</span>;

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

 <span>?></span></span></span></code>
Copy after login
'). addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced a simple PHP guestbook example review, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template