新微赢技术网

标题: 怎样将此"修改页面"和"修改后处理页面"合二为一 [打印本页]

作者: 人偶娃娃    时间: 2010-1-17 04:01
标题: 怎样将此"修改页面"和"修改后处理页面"合二为一
'修改页面
<%
strID = Request("tID")
set conn = Server.CreateObject("ADODB.Connection")
conn.Open("driver={SQL Server};database=pubs;server=(LOCAL);uid=sa;pwd=111111")
strSQL = "select * from txl Where tID ="&strID
set rs = conn.Execute(strSQL)
%>
<form name="form1" method="post" action="modifySumit.asp">
<% '输出表的内容
If not rs.EOF Then
%>
<table align="center" width="361" border="0"style="color:#3E96A6 ">
<tr>
<td align="center" bgcolor="#3E96A6"><span class="style11"><%=rs("tName")%>的通讯录</span></td>
</tr>
</table>
<table width="361" border="0" align="center" cellpadding="1">
<tr>
<td width="132">&nbsp;</td>
<td width="219"><input type="hidden" name="tID" value="<%=rs("tID")%>"></td>
</tr>
<tr>
<td><span class="style7">EMAIL:</span></td>
<td><input name="tEmail" type="text" size="30" value="<%=rs("tEmail")%>"></td>
</tr>
<tr>
<td><span class="style7">手机号码:</span></td>
<td><input name="tMobile" type="text" size="30"value="<%=rs("tMobile")%>"></td>
</tr>
<tr>
<td><span class="style7">固定电话:</span></td>
<td><input name="tHomePhone" type="text" size="30"value="<%=rs("tHomePhone")%>"></td>
</tr>
<tr>
<td align="left" valign="top"><p class="style7">QQ:</p></td>
<td><input name="tQQ" type="text" size="30"value="<%=rs("tQQ")%>"></td>
</tr>
<tr>
<td align="left" valign="top"><span class="style7">备注:</span></td>
<td><span class="style7">
<textarea name="tMemo" cols="29" rows="3"><%=rs("tMemo")%></textarea>
</span></td>
</tr>
<tr>
<td align="left" valign="top">&nbsp;</td>
<td><span class="style7">
<input type="submit" name="Submit" value="修改完毕">
</span></td>
</tr>
</table>
<%
End If
%>
</form>


修改后处理页面:
<%
tID = TRIM( REQUEST("tID"))
tEmail = TRIM( REQUEST("tEmail"))
tMobile = TRIM( REQUEST("tMobile"))
tHomePhone = TRIM( REQUEST("tHomePhone"))
tQQ = TRIM( REQUEST("tQQ"))
tMemo = TRIM( REQUEST("tMemo"))

set conn = Server.CreateObject("ADODB.Connection")
conn.Open("driver={SQL Server};database=pubs;server=127.0.0.1;uid=sa;pwd=111111")
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
SQL = "UPDATE txl SET tEmail='"&tEmail&"',tMobile='"&tMobile&"',tHomePhone='"&tHomePhone&"',tQQ='"&tQQ&"',tMemo='"&tMemo&"' Where tID="&tID
Response.Write(SQL)
cmd.CommandText = SQL
cmd.Execute()
Response.Redirect("index.asp")
%>


据说用IF ...ELSE.....THEN ....语句可以将此两个程序写在一起,敬请指点!!!
作者: 飘林飞遥    时间: 2010-1-17 04:01
修改后处理页面:
<%
tID = TRIM( REQUEST("tID"))
tEmail = TRIM( REQUEST("tEmail"))
tMobile = TRIM( REQUEST("tMobile"))
tHomePhone = TRIM( REQUEST("tHomePhone"))
tQQ = TRIM( REQUEST("tQQ"))
tMemo = TRIM( REQUEST("tMemo"))

set conn = Server.CreateObject("ADODB.Connection")
conn.Open("driver={SQL Server};database=pubs;server=127.0.0.1;uid=sa;pwd=111111")
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
SQL = "UPDATE txl SET tEmail='"&tEmail&"',tMobile='"&tMobile&"',tHomePhone='"&tHomePhone&"',tQQ='"&tQQ&"',tMemo='"&tMemo&"' Where tID="&tID
Response.Write(SQL)
cmd.CommandText = SQL
cmd.Execute()
Response.Redirect("index.asp")
%>




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2