當前位置:編程學習大全網 - 源碼下載 - asp註冊登陸代碼

asp註冊登陸代碼

1,(index.asp 用戶登陸頁面)

<!-- #include file="conn.asp" -->

<!-- blog.soowooo.cn 悠悠長假期 -->

<html>

<head>

<meta p(nr,request.Form("password"))=0 then

response.Write("歡迎妳!"&request.Form("username"))

response.Write("妳是在"&vv&"註冊的")

session("username")=request.Form("username")

end if

if session("username")="" then

response.Redirect("index.asp")

end if

%>

<form name="form1" method="post" action="change.asp?ac=ch">

<table width="39%" height="105" border="0" >

<tr>

<td width="27%" height="30">用戶名:</td>

<td width="73%" height="30"><input name="username" type="text" id="username" value="<%=username%>">

*</td>

</tr>

<tr>

<td height="30">密 碼:</td>

<td height="30"><input name="password" type="text" id="password" value="<%=password%>">

*</td>

</tr>

<tr>

<td height="30">性 別:</td>

<td height="30"><input name="sex" type="text" id="sex" value="<%=sex%>"></td>

</tr>

<tr>

<td height="30">QQ:</td>

<td height="30"><input name="qq" type="text" id="qq" value="<%=qq%>"></td>

</tr>

<tr>

<td height="30">Mail:</td>

<td height="30"><input name="mail" type="text" id="mail" value="<%=mail%>"></td>

</tr>

<tr>

<td height="30">地 址:</td>

<td height="30"><input name="add" type="text" id="add" value="<%=add%>"></td>

</tr>

<tr>

<td>介紹</td>

<td><textarea name="personalinfo" cols="30" rows="6" id="personalinfo"><%=personalinfo%></textarea></td>

</tr>

<tr>

<td> </td>

<td><input type="submit" name="Submit" value="修改">

<a href="change.asp?se=y" target="_self">退出系統</a></td>

<% if strcomp(request.QueryString("se"),"y")=0 then

session("username")=""

response.Redirect("index.asp")

end if

%>

</tr>

</table>

</form>

<%

if strcomp(request.QueryString("ac"),"ch")=0 then

set rs=server.createobject("adodb.recordset")

sql="select * from info where username='"&session("username")&"'"

rs.open sql,conn,1,3

rs("username")=request.Form("username")

rs("password")=request.Form("password")

rs("mail")=request.Form("mail")

rs("sex")=request.Form("sex")

rs("qq")=request.Form("qq")

rs("add")=request.Form("add")

rs("personalinfo")=request.Form("personalinfo")

rs.update

set rs=nothing

response.Write("修改完成!")

end if

%>

</body>

</center>

</html>

4,(reg.asp 新用戶註冊頁面)

<html>

<head>

<meta p(cstr(request.Form("password")),cstr(request.Form("password2")))<>0 then

msg=msg&"<br>"&"兩次密碼輸入不同"

end if

if len(request.Form("password"))<6 then

msg=msg&"<br>"&"密碼太簡單"

end if

if strcomp(msg,"註冊錯誤信息")>0 then

response.Redirect("reg.asp?msg="&msg)

end if

if ac="adduser" then

set rsc=server.createobject("adodb.recordset")

sql="select * from info where username='"&request.Form("username")&"'"

rsc.open sql,conn,1,1

ck=rsc("username")

set rsc=nothing

if ck<>"" then

msg=msg&"<br>"&"用戶名被人註冊"

response.Redirect("reg.asp?msg="&msg)

end if

dsql="select * from info where id is null"

set rs=server.createobject("adodb.recordset")

rs.open dsql,conn,1,3

rs.addnew

rs("username")=request.Form("username")

rs("password")=request.Form("password")

rs("mail")=request.Form("mail")

rs("sex")=request.Form("sex")

rs("qq")=request.Form("qq")

rs("add")=request.Form("add")

rs("personalinfo")=request.Form("personalinfo")

rs("ntime")=now

rs.update

set rs=nothing

%>

<center>

<a href="index.asp" target="_self">註冊成功,點擊登陸</a>

</center>

<%

end if

%>

</body>

</html>

6,(conn.asp 數據庫連接文件)

<%

'連接數據庫開始

dim conn,rs,sql

on error resume next

dbpath=server.mappath("userinfo.mdb")

set conn=server.createobject("adodb.connection")

conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="&dbpath

'創建記錄對象

set rs=server.createobject("adodb.recordset")

%>

7,(userinfo.mdb ACCESS 數據庫)

在ACCESS中建壹個表,然後在這個表中建立字段名稱

表名:info

字段名稱 數據類型

id 自動編號

username 文本

password 文本

sex 文本

quest 文本

qq 文本

mail 文本

personalinfo 文本

ntime 文本

  • 上一篇:怎樣用C語言制作圖書館管理系統
  • 下一篇:蘋果5手機越獄顯示成功但不能新增源
  • copyright 2024編程學習大全網