< ! --function.php-- >
    //header('Content-Type:text/html;charset:utf-8');
    error_reporting(0);
    class Con_sqlite
    {
  function get_sqlite_con()
  {
      $db=new SQliteDatabase('liuyan');
      $sql="create table liu (id integer primary key not null,name varchar(20),content varchar(500) )";
      $db->query($sql);
      /*$sql2="insert into liu (name,content) values('kk','ffffffdiekl')";
      $db->query($sql2);*/
      return $db;
  }
    }
?>
 
< ! --index.php-- >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
    //header('Content-Type:text/html;charset:utf-8');
    include('function.php');
    $db_sqlite=new Con_sqlite;
    $db=$db_sqlite->get_sqlite_con();
    $sql="select * from liu";
    $res=$db->query($sql);
    $arr=$res->fetchAll(SQLITE_ASSOC);
?>
< body >

< h3 align ="center" >简单留言本 h3>
< table align ="center" width ="700" bordercolor ="#006666" border ="1" >
    foreach($arr as $row)
    {?>
   < tr > < td >编号: < ?=$row['id']? > td> < td >标题: < ?=$row['name'] ? > td> < td align ="right" width ="50" > < a href="del.php?id=>">删除 a> td> tr>     < tr > < td colspan ="2" valign ="top" height ="50" > < ?=$row['content']? > td> tr>
        }
?>
table>
< h3 align ="center" class ="STYLE1" >我要留言 h3>
< form id ="form1" name ="form1" method ="post" action ="add.php" >
   < table width ="700" border ="1" align ="center" >
     < tr >
       < td width ="15%" align ="right" valign ="bottom" >姓名: td>
       < td > < input name ="name" type ="text" size ="77" /> td>
     tr>
     < tr >
       < td align ="right" valign ="bottom" >内容: td>
       < td > < textarea name ="content" cols ="60" rows ="8" > textarea> td>
     tr>
     < tr >
       < td >  td>
       < td > < input type ="submit" name ="Submit" value ="提交" /> td>
     tr>
   table>
form>
body>
 
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >发表留言 title>
head>
< ! --add.php-- >
< body >
    include('function.php');
    $db_sqlite=new Con_sqlite;
    $db=$db_sqlite->get_sqlite_con();
    $name=$_POST['name'];
    $content=$_POST['content'];
    $add_sql="insert into liu (name,content) values ('$name','$content')";
    if($db->query($add_sql))
    {
  echo " < script >alert('留言成功') script>";
  echo " < script >location.href='index.php' script>";
    }
?>
body>
html>
 
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >删除留言 title>
head>
< ! --del.php-- >
< body >
    include('function.php');
    $db_sqlite=new Con_sqlite;
    $db=$db_sqlite->get_sqlite_con();
    $id=$_GET['id'];
    $del_sql="delete from liu where id=$id";
    if($db->query($del_sql))
    {
  echo " < script >alert('删除成功') script>";
  echo " < script >location.href='index.php' script>";
    }else
    {
  echo " < script >alert('删除失败'); script>";
  echo " < script >location.href='index.php' script>";
    }
?>
body>
html>