Conn.php
--------------------------------------------------------------------------------------------------------------------------------------------------------
/*数据库路径,请自己修改,否则可能运行不正常*/
$conn = @new COM("ADODB.Connection") or die ("ADO连接失败!");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("include/#mydb.mdb");
$conn->Open($connstr);
//创建记录集查询
?>
Add.php
$name=$_POST['user_name'];
$content=$_POST['user_post'];
if ($name<>"" and $content<>"")
{
if($name="admin" or $content="admin")
{
echo "";
}
include_once("include/conn.php");
$rs = $conn->Execute("insert into contents (name,content) values ('$name','$content')");
header("location:index.php");
}
else
echo "";
?>
Del.php
session_start();
if($_SESSION['admin']=="OK")
{
include_once("include/conn.php");
$sql="delete from contents where id=".$_GET['id'];
$rs = $conn->Execute($sql);
header("location:admin_index.php");
}
?>
Show.php
session_start();
if($_SESSION['admin']=="OK")
{
include_once("include/conn.php");
$sql="select * from contents where id=".$_GET['id']; /*$_GET['id']是传递过来的参数 */
$rs = $conn->Execute($sql);
$name=$rs->Fields['name']->Value;
$content=$rs->Fields['content']->Value;
$id=$rs->Fields['id']->Value;
?>
ID :=$id?> >
姓名:=$name?>
留言:=$content?>
}
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
Edit.php
session_start();
if($_SESSION['admin']=="OK")
{
include_once("include/conn.php");
$sql="update contents set content='".$_POST['post_contents']."' where id=".$_POST['id'];
$rs = $conn->Execute($sql);
}
header("location:admin_index.php");
?>