📄 insertadmin.aspx
字号:
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Web.Security" %>
<script language="VB" runat="Server">
Dim objConn As OleDbConnection
Dim strSQL As String
Sub Page_Load(Sender As Object, E as EventArgs)
end sub
Function Get_DSN(bolSQL As Boolean) As String
'--- bolSQL: True for SQL Server, False for Access ---
If Not bolSQL Then 'Access
Get_DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Server.MapPath("database.mdb")
Else 'SQL Server
Get_DSN = "Provider=SQLOLEDB.1;Data Source=Alvinnt;User ID=sa;" _
& "Password=;Initial Catalog=ASPNew;autotranslate=no;"
End If
End Function
Function Checkuser(user As String) As Boolean
Dim objDR As OleDbDataReader
Dim objCmd As OleDbCommand
strSQL = "select * from master where user='" & textbox1.text & "'"
objCmd = New OleDbCommand(strSQL, objConn)
objCmd.Connection.Open()
objDR = objCmd.ExecuteReader()
Checkuser = False
While objDR.Read()
Checkuser = True
End While
objCmd.Connection.Close()
End Function
Sub onclick1(Sender As Object, E As EventArgs)
Dim objCmd As OleDbCommand
Dim strDSN,user As String
strDSN = Get_DSN(False)
objConn = New OleDbConnection(strDSN)
If Not Checkuser(user) and textbox3.text=textbox2.text and textbox1.text<>"" Then
strSQL = " insert into master values('" + textbox1.text + "','" + FormsAuthentication.HashPasswordForStoringInConfigFile(textbox2.Text, "sha1") +"')"
objConn = New OleDbConnection(strDSN)
objCmd = New OleDbCommand(strSQL, objConn)
objCmd.Connection.Open()
objCmd.ExecuteNonQuery()
objCmd.Connection.Close()
textbox3.text=""
textbox2.text=""
Response.Write("<center><font color='red'>")
Response.Write("恭喜你。你已经正式成为系统管理员。请记好的注册名和密码!!")
Response.Write("<hr><a href='/default.aspx'>")
Response.Write("回主页</a></font>")
else
textbox3.text=""
textbox2.text=""
Response.Write("<center><font color='red'>")
Response.Write("注意,项目没有填写完整或者输入的注册名已经存在!!")
Response.Write("<hr><a href='javascript:history.go(-1)'>")
Response.Write("回前一画面</a></font>")
End If
End Sub
Sub onclick2(Sender As Object, E As EventArgs)
textbox1.text=""
textbox2.text=""
textbox3.text=""
End Sub
</script>
<html>
<head><title>致远工作室音像资料管理系统</title></head>
<body>
<link href="styles.css" type=text/css rel=stylesheet>
<form runat="server"><br><br>
<table border="1" align="center" width="700" bordercolor="0066cc" background="img/bg.gif">
<tr>
<td>
<table border="1" align="center" bordercolor="0066cc" >
<tr>
<td>致远工作室音像资料管理系统
</td>
</tr>
</table>
<hr>
<table border="1" align="center" bordercolor="0066cc" >
<tr>
<td>注册名:</td>
<td><asp:textbox id="textbox1" runat="server"/></td><td>*用于登陆VIP的帐号(请不要写中文注册名)</td>
</tr>
<tr>
<td>密 码:</td>
<td><asp:textbox id="textbox2" textmode="password" runat="server"/></td><td>*用于登陆VIP的密码</td>
</tr>
<tr>
<td>重复密码:</td>
<td><asp:textbox id="textbox3" textmode="password" runat="server"/></td><td>*确认您的密码(与上面相同)</td>
</tr>
<tr>
<td>
<asp:button id="button1" text=" 确 定 " onclick="onclick1" runat="server"/></td>
<td align="center">
<asp:button id="button2" text=" 取 消 " onclick="onclick2" runat="server"/></td><td>*为必须填写项目</td>
</tr>
</table><br>
<center><a href="/default.aspx">返回首页</a>
<hr>
<center>
<asp:label id="label1" runat="server"/>
</td></tr></table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -