简单的php留言本例子温习

原创
2016-07-28 08:29:11 747浏览

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

<htmlxmlns="http://www.w3.org/1999/xhtml"lang="zh-CN"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>10title><metaname="description"content="" />head><body><formaction="10.php"method="post"><inputtype="text"name="title"/><inputtype="text"name="content"/><inputtype="submit" />form>body>html>

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

$str=$_POST['title'].','.$_POST['content']. "\n";

$fh=fopen('1.txt', 'a');

fwrite($fh, $str);

fclose($fh);

echo"ok";


 ?>

msg.php 留言本标题列表页

    header("Content-Type:text/html;charset=utf8");

    $fh=fopen('1.txt', 'r');

    $i=1;

    while (($str = fgetcsv($fh))!=false) {
        echo'
  • ',$str[0],'
  • '
    ; $i=$i+1; } ?>

    redmsg.php 内容页

        header("Content-Type:text/html;charset=utf8");
    
        $fh=fopen('1.txt', 'r');
    
        $i=1;
    
        while (($str = fgetcsv($fh))!=false) {
    
            if ($i==$_GET['tid']) {
                echo'
  • ',$str[0],'

  • '
    ; echo'
  • ',$str[1],'

  • '
    ; } $i=1+$i; } ?>

    ').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

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

  • 声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。