一个关于表单提交的ASP的问题~
想通过此表单提交一页面后,实现记录的修改功能,请问更新页面该如何写,谢谢~~表单代码如下:)<!--#includefile="check.asp"--><%dimaa=...
想通过此表单提交一页面后,实现记录的修改功能,请问更新页面该如何写,谢谢~~表单代码如下:)
<!--#include file="check.asp"-->
<%
dim a
a= Request.QueryString("stunum")
%>
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="inc/style.css" type=text/css rel=stylesheet>
</head>
<body text="#000000">
<!--#include file="head.asp"-->
<form name="form1" method="post" action="stuupdate.asp">
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<tr height="22" valign="middle" align="center">
<td colspan=8>学号为<font color=red><%=a%></font>的同学详细情况</td>
</tr>
<tr height="22" valign="middle" align="center">
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>电话</th>
<th>手机</th>
<th>院系</th>
<th>宿舍</th>
<th>备注</th>
</tr>
<%
Dim ll
Set ll = Conn.Execute("Select * From stuinfo where stunum='"&a&"'")
Do While Not ll.Eof
%>
<tr valign="middle" bgcolor="#FFFFFF" align="center" height="22">
<td width="11%"><input name="stunum" type="text" value="<%=ll("stunum")%>" size="12"></td>
<td width="8%"><input name="name" type="text" value="<%=ll("name")%>" size="8"></td>
<td width="6%"><input name="sex" type="text" value="<%=ll("sex")%>" size="6"></td>
<td width="11%"><input name="tel" type="text" value="<%=ll("tel")%>" size="12"></td>
<td width="14%"><input name="mobile" type="text" value="<%=ll("mobile")%>" size="12"></td>
<td width="19%"><input name="yuanxi" type="text" value="<%=ll("yuanxi")%>" size="20"></td>
<td width="11%"><input name="sushe" type="text" value="<%=ll("sushe")%>" size="10"></td>
<td width="20%"><input name="beizhu" type="text" value="<%=ll("beizhu")%>" size="16"></td>
</tr>
<%
ll.MoveNext
Loop
ll.Close
Conn.Close
Set ll=Nothing
Set Conn=Nothing
%>
</table>
<p align="center">
<input type="submit" name="Submit" value="修改">
</p>
</form>
<!--#include file="foot.asp"-->
</body>
</html>
check.asp
<!-- #include file="conn.asp"-->
<%
Dim server_v1
Dim server_v2
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
response.write "<br><br><center><table border=0 cellpadding=20 width=450>"
response.write "<tr><td>"
response.write "不要外部提交,跳过Http提交吧!"
response.write "</td></tr></table></center>"
Response.Redirect("index.htm")
end if
%>
<%
Dim adu,adp,chk,aid
If Session("glname")="" or Session("glpwd")="" or Session("glid")="" Then
Response.Redirect "index.htm"
Else
adu = Session("glname")
adp = Session("glpwd")
aid = Session("glid")
Set chk = Conn.Execute("Select * From admin Where adname='"&adu&"' and adpwd='"&adp&"' and adtpid="&aid&"")
If chk.Eof and chk.Bof Then
Response.Redirect "index.htm"
End if
End if
chk.Close
Set chk=Nothing
%> 展开
<!--#include file="check.asp"-->
<%
dim a
a= Request.QueryString("stunum")
%>
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="inc/style.css" type=text/css rel=stylesheet>
</head>
<body text="#000000">
<!--#include file="head.asp"-->
<form name="form1" method="post" action="stuupdate.asp">
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<tr height="22" valign="middle" align="center">
<td colspan=8>学号为<font color=red><%=a%></font>的同学详细情况</td>
</tr>
<tr height="22" valign="middle" align="center">
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>电话</th>
<th>手机</th>
<th>院系</th>
<th>宿舍</th>
<th>备注</th>
</tr>
<%
Dim ll
Set ll = Conn.Execute("Select * From stuinfo where stunum='"&a&"'")
Do While Not ll.Eof
%>
<tr valign="middle" bgcolor="#FFFFFF" align="center" height="22">
<td width="11%"><input name="stunum" type="text" value="<%=ll("stunum")%>" size="12"></td>
<td width="8%"><input name="name" type="text" value="<%=ll("name")%>" size="8"></td>
<td width="6%"><input name="sex" type="text" value="<%=ll("sex")%>" size="6"></td>
<td width="11%"><input name="tel" type="text" value="<%=ll("tel")%>" size="12"></td>
<td width="14%"><input name="mobile" type="text" value="<%=ll("mobile")%>" size="12"></td>
<td width="19%"><input name="yuanxi" type="text" value="<%=ll("yuanxi")%>" size="20"></td>
<td width="11%"><input name="sushe" type="text" value="<%=ll("sushe")%>" size="10"></td>
<td width="20%"><input name="beizhu" type="text" value="<%=ll("beizhu")%>" size="16"></td>
</tr>
<%
ll.MoveNext
Loop
ll.Close
Conn.Close
Set ll=Nothing
Set Conn=Nothing
%>
</table>
<p align="center">
<input type="submit" name="Submit" value="修改">
</p>
</form>
<!--#include file="foot.asp"-->
</body>
</html>
check.asp
<!-- #include file="conn.asp"-->
<%
Dim server_v1
Dim server_v2
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
response.write "<br><br><center><table border=0 cellpadding=20 width=450>"
response.write "<tr><td>"
response.write "不要外部提交,跳过Http提交吧!"
response.write "</td></tr></table></center>"
Response.Redirect("index.htm")
end if
%>
<%
Dim adu,adp,chk,aid
If Session("glname")="" or Session("glpwd")="" or Session("glid")="" Then
Response.Redirect "index.htm"
Else
adu = Session("glname")
adp = Session("glpwd")
aid = Session("glid")
Set chk = Conn.Execute("Select * From admin Where adname='"&adu&"' and adpwd='"&adp&"' and adtpid="&aid&"")
If chk.Eof and chk.Bof Then
Response.Redirect "index.htm"
End if
End if
chk.Close
Set chk=Nothing
%> 展开
2个回答
展开全部
<!--#include file="check.asp"-->
<%
dim a
a= Request.QueryString("stunum")
%>
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="inc/style.css" type=text/css rel=stylesheet>
</head>
<body text="#000000">
<!--#include file="head.asp"-->
<form name="form1" method="post" action="">
<% if request("post")<>"" then
call write1
end if
function write1
set rs=server.createobject("adodb.recordset")
sql="Select * from stuinfo where stunum='"&a&"'"
rs.open sql,conn,1,3
rs("stunum")=request("stunum")
rs("name")=request("name")
rs("sex")=request("sex")
rs("tel")=request("tel")
rs("mobile")=request("mobile")
rs("yuanxi")=request("yuanxi")
rs("sushe")=request("sushe")
rs("beizhu")=request("beizhu")
rs.update
rs.close
response.Write("<script language=javascript>alert('修改成功');location='stuupdate.asp'</script>")
end function
%>
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<input name="post" type="hidden" id="post" value="true">
<tr height="22" valign="middle" align="center">
<td colspan=8>学号为<font color=red><%=a%></font>的同学详细情况</td>
</tr>
<tr height="22" valign="middle" align="center">
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>电话</th>
<th>手机</th>
<th>院系</th>
<th>宿舍</th>
<th>备注</th>
</tr>
<%
Dim ll
Set ll = Conn.Execute("Select * From stuinfo where stunum='"&a&"'")
Do While Not ll.Eof
%>
<tr valign="middle" bgcolor="#FFFFFF" align="center" height="22">
<td width="11%"><input name="stunum" type="text" value="<%=ll("stunum")%>" size="12"></td>
<td width="8%"><input name="name" type="text" value="<%=ll("name")%>" size="8"></td>
<td width="6%"><input name="sex" type="text" value="<%=ll("sex")%>" size="6"></td>
<td width="11%"><input name="tel" type="text" value="<%=ll("tel")%>" size="12"></td>
<td width="14%"><input name="mobile" type="text" value="<%=ll("mobile")%>" size="12"></td>
<td width="19%"><input name="yuanxi" type="text" value="<%=ll("yuanxi")%>" size="20"></td>
<td width="11%"><input name="sushe" type="text" value="<%=ll("sushe")%>" size="10"></td>
<td width="20%"><input name="beizhu" type="text" value="<%=ll("beizhu")%>" size="16"></td>
</tr>
<%
ll.MoveNext
Loop
ll.Close
Conn.Close
Set ll=Nothing
Set Conn=Nothing
%>
</table>
<p align="center">
<input type="submit" name="Submit" value="修改">
</p>
</form>
<!--#include file="foot.asp"-->
</body>
</html>
这回应该没问题了,
你是不是完全把我这段代码复制粘贴的?
还是你自己根据我这个改的?
这里面要添加一个隐藏input
如果是改的你看你加没加????
把你的check.asp也贴出来,这段代码肯定没错的
<%
dim a
a= Request.QueryString("stunum")
%>
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="inc/style.css" type=text/css rel=stylesheet>
</head>
<body text="#000000">
<!--#include file="head.asp"-->
<form name="form1" method="post" action="">
<% if request("post")<>"" then
call write1
end if
function write1
set rs=server.createobject("adodb.recordset")
sql="Select * from stuinfo where stunum='"&a&"'"
rs.open sql,conn,1,3
rs("stunum")=request("stunum")
rs("name")=request("name")
rs("sex")=request("sex")
rs("tel")=request("tel")
rs("mobile")=request("mobile")
rs("yuanxi")=request("yuanxi")
rs("sushe")=request("sushe")
rs("beizhu")=request("beizhu")
rs.update
rs.close
response.Write("<script language=javascript>alert('修改成功');location='stuupdate.asp'</script>")
end function
%>
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<input name="post" type="hidden" id="post" value="true">
<tr height="22" valign="middle" align="center">
<td colspan=8>学号为<font color=red><%=a%></font>的同学详细情况</td>
</tr>
<tr height="22" valign="middle" align="center">
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>电话</th>
<th>手机</th>
<th>院系</th>
<th>宿舍</th>
<th>备注</th>
</tr>
<%
Dim ll
Set ll = Conn.Execute("Select * From stuinfo where stunum='"&a&"'")
Do While Not ll.Eof
%>
<tr valign="middle" bgcolor="#FFFFFF" align="center" height="22">
<td width="11%"><input name="stunum" type="text" value="<%=ll("stunum")%>" size="12"></td>
<td width="8%"><input name="name" type="text" value="<%=ll("name")%>" size="8"></td>
<td width="6%"><input name="sex" type="text" value="<%=ll("sex")%>" size="6"></td>
<td width="11%"><input name="tel" type="text" value="<%=ll("tel")%>" size="12"></td>
<td width="14%"><input name="mobile" type="text" value="<%=ll("mobile")%>" size="12"></td>
<td width="19%"><input name="yuanxi" type="text" value="<%=ll("yuanxi")%>" size="20"></td>
<td width="11%"><input name="sushe" type="text" value="<%=ll("sushe")%>" size="10"></td>
<td width="20%"><input name="beizhu" type="text" value="<%=ll("beizhu")%>" size="16"></td>
</tr>
<%
ll.MoveNext
Loop
ll.Close
Conn.Close
Set ll=Nothing
Set Conn=Nothing
%>
</table>
<p align="center">
<input type="submit" name="Submit" value="修改">
</p>
</form>
<!--#include file="foot.asp"-->
</body>
</html>
这回应该没问题了,
你是不是完全把我这段代码复制粘贴的?
还是你自己根据我这个改的?
这里面要添加一个隐藏input
如果是改的你看你加没加????
把你的check.asp也贴出来,这段代码肯定没错的
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这句应该是
<form
name="form1"
method="post"
action="savestuupdate.asp?stunum=<%=stunum%>">
savestuupdate.asp代码
<%
set
rs=server.createobject("adodb.recordset")
sql="selece
*
from
[表名]
where
stunum="&clng(request("stunum"))
rs.open
sql,conn,1,3
rs("字段1")=request("相应输入框")
'stuupdate.asp页面中的相应输入框
。。。。其他的字段自己加
rs.update
rs.close
set
rs=nothing
%>
数据库连接的自己写~
<form
name="form1"
method="post"
action="savestuupdate.asp?stunum=<%=stunum%>">
savestuupdate.asp代码
<%
set
rs=server.createobject("adodb.recordset")
sql="selece
*
from
[表名]
where
stunum="&clng(request("stunum"))
rs.open
sql,conn,1,3
rs("字段1")=request("相应输入框")
'stuupdate.asp页面中的相应输入框
。。。。其他的字段自己加
rs.update
rs.close
set
rs=nothing
%>
数据库连接的自己写~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询