...登录跳转不到登录后的页面,跳转的是登录不成功界面
发布网友
发布时间:2024-09-25 19:06
我来回答
共2个回答
热心网友
时间:2024-10-14 22:33
我们学的是asp的连接sql数据库,我把代码给你参考一下:
登陆的:
<form action="findhistory.asp" method="post">
<table width="362" border="0">
<tr>
<td colspan="2">您的位置:登陆页面</td>
</tr>
</table>
<hr align="center" width="500" />
<table width="362" border="0">
<tr>
<td width="140"><div align="right">会员名:</div></td>
<td width="212"><label>
<input name="logname" type="text" size="20" />
</label></td>
</tr>
<tr>
<td><div align="right">密码:</div></td>
<td><label>
<input name="passwd" type="password" size="21" />
</label></td>
</tr>
<tr>
<td colspan="2" align="left">
<div style="margin-left:60px; margin-top:10px; line-height:22px;">忘记用户名(请联系管理员)<br />
<a href="wjmm.asp" style="text-decoration:underline; color:#666;">忘记密码</a></div>
</td>
</tr>
<tr align="center">
<td colspan="2"><label>
<input type="submit" name="ss" value="提交" />
</label>
<label>
<input type="reset" name="s2" value="重置" />
</label></td>
</tr>
</table>
</form>
findhistory.asp的内容:
<%
logn=trim(request.form("logname"))
pwd=trim(request.form("passwd"))
if logn="" then
response.write("<h2>你的操作有误,<a href=denglu.asp>请重试!</a></h2>")
response.end
end if
dim login
if logn="" or pwd="" then
response.write("<p>会员名、密码不能为空!</p>")
response.redirect("tishi.asp")
end if
set conn=server.CreateObject("ADODB.Connection")
connstring="provider=sqloledb.1; uid=sa; pwd=123456; Initial Catalog=shg; Data Source=(local)"
conn.Open(connstring)
set rs=Server.CreateObject("ADODB.Recordset")
sql1="select * from sun where huiyuanming='" & logn & "'and mima='" & pwd &"'"
set rs=conn.execute(sql1)
if rs.eof then
response.write("<p>会员名不存在或者会员名、密码错误!</p>")
response.redirect("tishi.asp")
else
response.write("<p>登陆成功!<a href='search.asp'>继续购物</a></p>")
session("login")=session.SessionID
session("id")=logn
session("loginuser")=rs("huiyuanming")
rs.close
set rs=nothing
end if
%>
注册的:
<form name="form8"action="zhuceok.asp" method="post">
<table width="372" border="0">
<tr>
<td colspan="2">您的位置:注册页面</td>
</tr>
</table>
<hr align="left" width=362>
<table width="372" border="0">
<tr>
<td width="95">会员名:</td>
<td width="153"><label>
<input name="t1" type="text" size="20" />
</label></td>
<td width="110"><span class="STYLE1">*用户名长度为3-8</span></td>
</tr>
<tr>
<td>密 码:</td>
<td><label>
<input name="t2" type="password" size="21" />
</label></td>
<td><span class="STYLE1">*密码长度为4-8</span></td>
</tr>
<tr>
<td>确认密码:</td>
<td><label>
<input name="t3" type="password" size="21" />
</label></td>
<td> </td>
</tr>
<tr>
<td>您的姓名:</td>
<td><label>
<input name="t4" type="text" size="20" />
</label></td>
<td> </td>
</tr>
<tr>
<td>身份证号:</td>
<td><label>
<input name="t5" type="text" size="20" />
</label></td>
<td> </td>
</tr>
<tr>
<td>性 别:</td>
<td><label>
<input name="sex" type="radio" value="男" checked="checked" />
男 </label>
<label>
<input type="radio" name="sex" value="女" />
女 </label></td>
<td> </td>
</tr>
<tr>
<td>您的年龄:</td>
<td><label>
<select name="select">
<option>1980</option>
<option>1981</option>
<option>1982</option>
<option>1983</option>
<option>1984</option>
<option>1985</option>
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
</select>
</label></td>
<td> </td>
</tr>
<tr>
<td valign="top">详细地址:</td>
<td><label>
<textarea name="textarea" cols="19" rows="2" ></textarea>
</label></td>
<td> </td>
</tr>
<tr>
<td>电话号码:</td>
<td><label>
<input name="t6" type="text" size="20" />
</label></td>
<td> </td>
</tr>
<tr>
<td>电子邮箱:</td>
<td><label>
<input name="t7" type="text" size="20" />
</label></td>
<td class="STYLE1">*填写正确的格式</td>
</tr>
<tr align="center">
<td colspan="3"><input name="ch1" type="checkbox" value="" checked="checked" />
<a href="yhxy.asp" style="color:#666;" target="_blank">我已阅读并同意《用户协议》</a>
</td >
</tr >
<tr align="center">
<td colspan="3"><label>
<input type="button" name="S1" value="提交" />
</label>
<label>
<input type="reset" name="S2" value="重置" />
</label></td>
</tr>
</table>
</form>
<script language="VBScript" type="text/VBScript">
sub s1_onclick()
if len(form8.t1.value)<3 then
msgbox "用户名太短,请选择一个长度大于3的名字!"
form8.t1.select
exit sub
end if
if instr(trim(form8.t1.value)," ")>1 then
msgbox "用户名中请不要加入空格!"
form8.t1.select
exit sub
end if
if len(form8.t2.value)<4 then
msgbox "密码太短,请输入一个长度大于4的密码!"
form8.t2.select
exit sub
end if
if trim(form8.t2.value)<>trim(form8.t3.value) then
msgbox "密码不相同!"
form8.t3.select
exit sub
end if
if instr(form8.t7.value,"@")<=1 then
msgbox "请输入正确的邮箱地址!"
form8.t7.select
exit sub
end if
if form8.ch1.checked<>true then
msgbox"请同意本公司《用户协议》后再注册!"
form8.ch1.select
exit sub
end if
form8.submit
end sub
</script>
恭喜你,你的注册成功:<br>
<%
function sqlstr(data)
sqlstr="'" & replace(data,"'","''") & "'"
end function
dim hym,mm,xm,sfz,xb,nl,dz,dh,em
hym=request.form("t1")
mm=request.form("t2")
xm=request.form("t4")
sfz=request.form("t5")
xb=request.form("sex")
nl=request.form("select")
dz=request.form("textarea")
dh=request.form("t6")
em=request.form("t7")
Response.write("会员名:" & hym & "<br>")
Response.write("密码:" & mm & "<br>")
Response.write("姓名:" & xm & "<br>")
Response.write("身份证:" & sfz & "<br>")
Response.write("性别:" & xb & "<br>")
Response.write("年龄:" & nl & "<br>")
Response.write("详细地址:" & dz & "<br>")
Response.write("联系电话:" & dh & "<br>")
Response.write("E_mail:" & em & "<br>")
set conn = Server.CreateObject("ADODB.Connection")
connstring="provider=sqloledb.1; uid=sa; pwd=123456; Initial Catalog=shg; Data Source=(local)"
conn.Open(connstring)
set rs=Server.CreateObject("ADODB.Recordset")
rs.activeconnection=conn
sql="select * from sun where huiyuanming="
sql=sql & sqlstr(hym)
rs.source=sql
rs.open
if not rs.eof then
response.write("对不起,你所申请的用户名已存在!请<a href='zhucexx.asp'>重新注册</a>")
rs.close
response.end
else
mysql="Insert Into sun(huiyuanming,mima,xingming,shenfenzheng,xingbie,nianling,dizhi,dianhua,email) values('" + hym +"','" + mm + "','"+ xm + "','"+ sfz + "','" + xb + "','" + nl + "','" + dz + "','" + dh + "','" + em + "')"
'Response.write(mysql)
conn.Execute(mysql)
Response.write("数据已插入!")
end if
%>
热心网友
时间:2024-10-14 22:32
跳转条件有错误