asp数据修改保存代码
asp教程数据修改保存代码
<!--#include file="conn.asp"-->
<%
if session("username")<>"admin" then
response.write "<script>alert('您不是系统管理员,没有此权限!');history.back()</script>"
session("passed")=false
else
%>
<html>
<head>
<title>用户修改</title>
</head>
<body>
<%
dim uid
uid=request.querystring("userid")
sql="select * from users where id=" & uid
'定义recordset对象
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof then
response.write ("<h2>不存在此用户名!</h2>")
else
%>
<form method="post" action="usersave.asp" name=myform onsubmit="return chkfield()">
<p align="center">用户基本信息</p>
<br><br><br>
<center>
<table border="0" width="371" id="table1">
<tr>
<td bgcolor="#c0c0c0" width="97" align="center">
<font size="2">用 户 名:</font>
</td>
<td width="260">
<%=rs("username")%>
<input type=hidden name=userid value=<%=rs("id")%>>
</td>
</tr>
<tr>
<td bgcolor="#c0c0c0" width="97" align="center">
<font size="2">用户姓名:</font>
</td>
<td width="260">
<input type=text name=ename size=20 value="<%=rs("ename")%>">
</td>
</tr>
<tr>
<td bgcolor="#c0c0c0" width="97" align="center">
<font size="2">电子邮箱:</font>
</td>
<td width="260">
<input type=text name=email size=20 value="<%=rs("email")%>">
</td>
</tr>
</table>
</center>
<p align="center">
<input type="submit" value="提交" name="b1">
<input type="reset" value="重置" name="b2">
</p>
</form>
<%end if%>
</body>
</html>
<%
end if
%>
处理文件
<!--#include file= "chkpwd.asp"-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>用户管理</title>
</head>
<body>
<%
userid = request.querystring("userid")
oripwd = request.form("oripwd")
pwd = request.form("pwd")
'判断是否存在此用户
set rs = server.createobject("adodb.recordset")
'sql = "select * from users where id = '"&userid&"'"
'rs.open sql,conn,1,1
rs.open "select * from users where id="&userid,conn,1,3
if rs.eof then
response.write("<hr><center>不存在此用户名!</h2><br><br><br>")
response.write("<input type = button name = close onclick = window.close() value = 关闭>")
elseif (rs("userpwd")<>md5(oripwd)) then
response.write("<hr><center>密码错误!</h2><br><br><br>")
response.write("<input type = button name = close onclick = window.close() value = 关闭>")
else
sql = "update users set userpwd= '"&md5(trim(pwd))&"' where id = "&userid
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
response.write("<hr><center>更改密码成功!</h2><br><br><br>")
response.write("<input type = button name = close onclick = window.close() value = 关闭>")
end if
%>
</body>
</html>
补充:asp教程,脚本编码