以下是引用lmhllr在2007-8-1 11:05:05的发言:
哦。。。完整的代码是怎么样的啊?
完整的
edit.php
<?php
session_start();
if($_SESSION['admin']=="OK")
{
require("config.inc.php");
$exec="select * from contents where id=".$_GET['id'];
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
$id=$rs->id;
$title=$rs->title;
$author=$rs->author;
$from=$rs->from;
$instruction=$rs->instruction;
$text=$rs->text;
?>
<form action="update.php" method="post">
<input type="hidden" name="id" name="<?= $id ?>" />
标题:<input type=text size=40 name="title" value=<?= $title ?> /><br>
作者:<input type=text size=40 name="author" value=<?= $author ?> /><br>
来源:<input type=text size=40 name="from" value=<?= $from ?> /><br>
说明:<br>
<textarea cols="40" rows="10" name="instruction" ><?= $instruction ?></textarea><br>
备注:<br>
<textarea cols="40" rows="10" name="text" ><?= $text ?></textarea><br>
<input type="submit" name="提交修改" value="提交修改" /><br><br><br>
</form>
<?php
}
else
{
head("location:login.htm");
}
mysql_close();
?>
update.php
<?php
$title=$_POST['title'];
$author=$_POST['author'];
$from=$_POST['from'];
$instruction=$_POST['instruction'];
$text=$_POST['text'];
$id=$_POST['id'];
session_start();
if($_SESSION['admin']=="OK")
{
require("config.inc.php");
$exec="select * from contents where id=".$_GET['id'];
$exec="UPDATE `contents` SET `title` = '$title',`author` = '$author',`from` = '$from',`instruction` = '$instruction', `text` = '$text' WHERE id=".$id;
$result=mysql_query($exec);
}
mysql_close();
header("location:admin_edit.php");
?>
一个表只有2个字段,只修改一个字段的话还可以用,可要修改的字段一多就没反应了