📄 add.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/cnn2.asp" -->
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="error.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_cnn2_STRING
MM_editCmd.CommandText = "INSERT INTO tuser (name, sex, birthday, tel, address) VALUES (?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 20, Request.Form("name")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 2, Request.Form("sex")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("birthday"), Request.Form("birthday"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 20, Request.Form("tel")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 50, Request.Form("address")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "browse.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<%
Dim rs1
Dim rs1_cmd
Dim rs1_numRows
Set rs1_cmd = Server.CreateObject ("ADODB.Command")
rs1_cmd.ActiveConnection = MM_cnn2_STRING
rs1_cmd.CommandText = "SELECT * FROM tuser"
rs1_cmd.Prepared = true
Set rs1 = rs1_cmd.Execute
rs1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加用户资料</title>
<style type="text/css">
<!--
@import url("../css/table.css");
-->
</style>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="bg1"><div align="center">用户资料管理系统——添加用户资料</div></td>
</tr>
<tr>
<td class="fk_table"><form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#FF0000">
<tr>
<td width="70" bgcolor="#33FF99"><div align="center">姓 名</div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input name="name" type="text" id="name" size="20" />
</div>
</label></td>
</tr>
<tr>
<td bgcolor="#33FF99"><div align="center">性 别</div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input type="radio" name="sex" id="radio" value="男" />
男
<input name="sex" type="radio" id="radio2" value="女" checked="checked" />
女</div>
</label></td>
</tr>
<tr>
<td bgcolor="#33FF99"><div align="center">生 日</div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input name="birthday" type="text" id="birthday" size="20" />
</div>
</label></td>
</tr>
<tr>
<td bgcolor="#33FF99"><div align="center">电 话</div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input name="tel" type="text" id="tel" size="20" />
</div>
</label></td>
</tr>
<tr>
<td bgcolor="#33FF99"><div align="center">地 址</div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input name="address" type="text" id="address" size="50" />
</div>
</label></td>
</tr>
<tr>
<td bgcolor="#33FF99"><div align="center"></div></td>
<td bgcolor="#33FF99"><label>
<div align="center">
<input type="submit" name="button" id="button" value="提交表单" />
<input type="reset" name="button2" id="button2" value="重新填写" />
</div>
</label><label></label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</td>
</tr>
<tr>
<td class="bg1"><div align="center">用户资料管理系统©版权所有</div></td>
</tr>
</table>
</body>
</html>
<%
rs1.Close()
Set rs1 = Nothing
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -