<%@ Language="VBScript" %> <!DOCTYPE html> <html> <head> <title>会员管理系统</title> </head> <body> <h1>会员管理系统</h1> <form method="post" action=""> <input type="hidden" name="action" value="register"> 用户名: <input type="text" name="username"><br> 密码: <input type="password" name="password"><br> 邮箱: <input type="email" name="email"><br> <input type="submit" value="注册"> </form> <hr> <form method="post" action=""> <input type="hidden" name="action" value="login"> 用户名: <input type="text" name="username"><br> 密码: <input type="password" name="password"><br> <input type="submit" value="登录"> </form> <hr> <% If Request.Form("action") = "login" Then %> <% Dim conn, rs, sql, username, password username = Request.Form("username") password = Request.Form("password") Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("members.mdb") sql = "SELECT * FROM members WHERE username='" & username & "' AND password='" & password & "'" Set rs = conn.Execute(sql) If Not rs.EOF Then Response.Write "欢迎 " & rs("username") & "!<br>" Response.Write "邮箱: " & rs("email") & "<br>" Response.Write "<a href='?action=edit&id=" & rs("id") & "'>编辑个人信息</a><br>" Response.Write "<a href='?action=logout'>退出登录</a>" Else Response.Write "用户名或密码错误!" End If rs.Close conn.Close Set rs = Nothing Set conn = Nothing End If %> <% If Request.QueryString("action") = "edit" Then %> <% Dim id, conn, rs, sql, username, email id = Request.QueryString("id") Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("members.mdb") sql = "SELECT * FROM members WHERE id=" & id Set rs = conn.Execute(sql) If Not rs.EOF Then username = rs("username") email = rs("email") End If rs.Close conn.Close Set rs = Nothing Set conn = Nothing %> <form method="post" action=""> <input type="hidden" name="action" value="update"> <input type="hidden" name="id" value="<%=id%>"> 用户名: <input type="text" name="username" value="<%=username%>"><br> 邮箱: <input type="email" name="email" value="<%=email%>"><br> <input type="submit" value="更新"> </form> <% End If %> <% If Request.Form("action") = "update" Then %> <% Dim id, username, email, conn, rs, sql id = Request.Form("id") username = Request.Form("username") email = Request.Form("email") Set conn = Server.CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("members.mdb") sql = "UPDATE members SET username='" & username & "', email='" & email & "' WHERE id=" & id conn.Execute(sql) conn.Close Set conn = Nothing Response.Redirect "?" %> <% End If %> <% If Request.QueryString("action") = "logout" Then %> <% Response.Redirect "" %> <% End If %> </body> </html>
这个示例使用了VBScript和ASP技术,需要将代码保存为.asp
文件并部署到支持ASP的Web服务器上(如IIS),需要一个名为members.mdb
的Access数据库文件,其中包含一个名为members
的表,具有以下字段:id
(自动编号)、username
、password
和email
。
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/1087832.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复