-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathedit.php
61 lines (56 loc) · 2.47 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<html>
<head>
<title>文章管理系统</title>
</head>
<body>
<center>
<?php
include("menu.php");//导入导航栏
//1.导入配置文件
require("dbconfig.php");
//2.连接MYSQL数据库、选择数据库
$link = @mysql_connect(HOST,USER,PASS) or die("数据库连接失败!");
mysql_select_db(DBNAME,$link);
//3.获取要修改信息的id号,并拼装查看sql语句,执行查询,获取要修改的信息
$sql = "select *from news where id={$_GET['id']}";
$result = mysql_query($sql,$link);
//4.判断是否获取到了要修改的信息
if($result &&mysql_num_rows($result)>0)
{
$news = mysql_fetch_assoc($result);
}else
{
die("没有找到要修改的信息!");
}
?>
<h3>编辑文章</h3>
<form action = "action.php?action=update" method="post">
<input type="hidden" name="id" value="<?php echo $news['id']; ?>" />
<table width="320" border="1">
<tr>
<td align="right">标题:</td>
<td><input type="text" name="title" value="<?php echo $news['title']; ?>" /></td>
</tr>
<tr>
<td align="right">关键字:</td>
<td><input type="text" name="keywords" value="<?php echo $news['keywords']; ?>" /></td>
</tr>
<tr>
<td align="right">作者:</td>
<td><input type="text" name="author" value="<?php echo $news['author']; ?>" /></td>
</tr>
<tr>
<td align="right" valign="top">内容:</td>
<td><textarea cols="25" rows="5" name="content"><?php echo $news['content']; ?></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="编辑"/>
<input type="reset" value="重置"/>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>