<form id="form1" name="form1" method="post" action="***.asp">
<p>用户名:<input type="text" name="n" /></p>
<p>密码:<input type="text" name="p" /></p>
<p><input type="submit" name="Submit" value="提交" /></p>
</form>
2、做一个数据库操作页面,也就是上面的那个***.asp
该页面首先链接到数据库,其次asp获取表单的提交信息,最后录入到数据库中。
分两步来讲:注册页面的写法(reg.asp)如下
<!--#include file="conn.asp"-->'conn.asp为资料库连接页面,注意路径
<form name=form1 method=post action="">
<input name=username type=text size=15><br>
<input name=password type=password size=15>
<input name=reg type=submit value=注册>
</form>
<%
if not isempty(request("reg")) then call reg()
sub reg()
username=request.form("username")
password=request.form("password")
if username="" or password="" then
response.write"<script>alert('请输入完善资料!')history.go(-1)</script>"
else
set rs=server.createobject("ADODB.Recordset")
sql="select * from [user] where name='"&username&"'"
rs.open sql,conn,3,3
if not rs.eof then
response.write"<script>alert('此帐号已注册')history.go(-1)</script>"
else
rs.addnew
rs("name")=username
rs("password")=password
rs.update
response.write"<script>alert('注册成功!')window.location='reg.asp'</script>"
rs.close
set rs=nothing
end if
end if
end sub
%>
'========================================
登录页面的写法(loging.asp)
<!--#include file="conn.asp"-->
<form name=form1 method=post action="">
<input name=username type=text size=15>
<input name=password type=text size=15>
<input naem=denglu type=submit value=登录>
</form>
<%
if not isempty(request("denglu")) then call denglu()
sub denglu()
username=request.form("username")
password=request.form("password")
if username="" or password="" then
response.write"<script>alert('请输入用户名或密码!')history.go(-1)</script>"
else
set rs=server.createobject("adodb.recordset")
sql="select * from [user] where name='"&username&"'"
rs.open sql,conn,3,3
if rs.eof then
response.write"<script>alert('你还没有注册!')history.go(-1)</script>"
elseif username=rs("name") and password=rs("password") then
response.write"登录成功后的导入页面.asp"
else
response.write"<script>alert('用户名或密码错误!')history.go(-1)</script>"
rs.close
set rs=nothing
end if
end if
end sub
%>
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)