php操作ACCESS(读写改)
2018-04-09 11:57
162 查看
Conn.php
---------------------------------------------------------------------------------------------------------------------------------------------------------
<?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
<?php
$name=$_POST['user_name'];
$content=$_POST['user_post'];
if ($name<>"" and
$content<>"")
{
if($name="admin"
or $content="admin")
{
echo
"<script
language='javascript'>alert('你要干什么!');location='index.php';</script>";
}
include_once("include/conn.php");
$rs =
$conn->Execute("insert into contents (name,content)
values ('$name','$content')");
header("location:index.php");
}
else
echo
"<script
language='javascript'>alert('字段不能有空!');location='index.php';</script>";
?>
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'];
$rs = $conn->Execute($sql);
$name=$rs->Fields['name']->Value;
$content=$rs->Fields['content']->Value;
$id=$rs->Fields['id']->Value;
?>
<form action="modify_save.php" method="post"
name="name1">
ID :<?=$id?><input
type="hidden" name="id"
value=<?=$id?> >
姓名:<?=$name?><br>
留言:<textarea
name="post_contents" rows="10"
cols="50"><?=$content?></textarea>
<input
type="submit" value="提交修改">
</form>
<?
}
$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");
?>
---------------------------------------------------------------------------------------------------------------------------------------------------------
<?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
<?php
$name=$_POST['user_name'];
$content=$_POST['user_post'];
if ($name<>"" and
$content<>"")
{
if($name="admin"
or $content="admin")
{
echo
"<script
language='javascript'>alert('你要干什么!');location='index.php';</script>";
}
include_once("include/conn.php");
$rs =
$conn->Execute("insert into contents (name,content)
values ('$name','$content')");
header("location:index.php");
}
else
echo
"<script
language='javascript'>alert('字段不能有空!');location='index.php';</script>";
?>
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'];
$rs = $conn->Execute($sql);
$name=$rs->Fields['name']->Value;
$content=$rs->Fields['content']->Value;
$id=$rs->Fields['id']->Value;
?>
<form action="modify_save.php" method="post"
name="name1">
ID :<?=$id?><input
type="hidden" name="id"
value=<?=$id?> >
姓名:<?=$name?><br>
留言:<textarea
name="post_contents" rows="10"
cols="50"><?=$content?></textarea>
<input
type="submit" value="提交修改">
</form>
<?
}
$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");
?>
相关文章推荐
- PHP文件读写操作相关函数学习资料笔记
- PHP使用XMLWriter读写xml文件操作详解
- PHP文件读写操作相关函数总结
- PHP读写文件的基本操作
- PHP多线程读写文件操作
- PHP文件读写操作
- php基础——文件读写操作
- 第二十三课:PHP中文件读写操作
- php读写文件操作
- Java IO操作——简单了解RandomAccessFile随机读写文件操作类的使用
- PHP中文件读写操作
- 使用Python对Access读写操作
- PHP读写文件高并发处理操作实例详解
- php读写操作hbase数据库的基本方法
- Java文件操作---RandomAccessFile随机读写文件操作
- php操作access数据库类代码
- php文件读写操作
- 一个PHP操作Access类(PHP+ODBC+Access)
- PHP中文件的读写操作
- PHP读写文件操作