注册登陆的简单问题??

nbshiny 2004-06-07 08:47:01
我想做一个注册页面regedit.asp,但是希望注册递交以后还是由regedit.asp来处理递交上来的数据,但是发现如果用户没有写姓名或者写密码,我如果发出对应的alert警告,结束后就不能返回原来的页面拉,页面提示一直要我输入空着的字符,我不知道怎么修改,请指教,最好有源码哦!,谢谢
...全文
108 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
nbshiny 2004-06-07
  • 打赏
  • 举报
回复
兄台,我搞不懂为什么我的 在main.asp页面中输入用户名,密码后,单击提交后,如果出现错误或者正常登陆,就是另外打开一个窗口,难道 Response.Redirect "main.asp"就是再另一个窗口中打开此页面吗,又没有办法实现再本页面打开新页面
zclzy520 2004-06-07
  • 打赏
  • 举报
回复
我一直是用一个页面完成的
看看吧
aaa.asp
<%
userName=trim(Request("userName"))
userpwd=trim(Request("userpwd"))
css=trim(Request("css"))
if css="1" then
response.Write "<script language='vbscript'>"
response.Write "msgbox " & chr(34) & "帐号未输入" & chr(34)
response.Write "</script>"
end if
if css="2" then
response.Write "<script language='vbscript'>"
response.Write "msgbox " & chr(34) & "密码未输入" & chr(34)
response.Write "</script>"
end if
if css="3" then
执行操作
end if
if username="" then
Response.Redirect "aaa.asp?css=1"
end if
if userpwd="" then
Response.Redirect "aaa.asp?css=2"
end if
if userName<>"" and userpwd<>"" then
Response.Redirect "aaa.asp?css=3"
end if
%>
<form id="form1" name="form1" action="aaa.asp">
<input id="userNam" name="userName">
<input type="password" id="userpwd" name="userpwd">
</form>
nbshiny 2004-06-07
  • 打赏
  • 举报
回复
if password = rs("passwd") then

session("num") = rs("num")
rs.close
set rs = nothing
conn.close
set conn = nothing
'response.redirect "zytm1.asp"
response.write "<script>window.location.href='zytm1.asp';</script>"
else
rs.close
set rs = nothing
conn.close
set conn = nothing

response.write "<script>alert('密码错误');window.location.href='main.asp';</script>"
end if

当前这个注册页面名字叫main.asp,每当我注册提交或者数据出错的时候,他会另外打开一个main。asp窗口,但是我想在一个窗口中完成,不知道该怎么修改上面的代码
  • 打赏
  • 举报
回复
你可以用dw2004自动生成

反正意思就是,如果每添,就不提交
Yjanuary 2004-06-07
  • 打赏
  • 举报
回复
<form name="Frmlogin" method="POST" action="本页面" onsubmit="return(in_chk());">
<script language="JavaScript">
function in_chk(){
if(Frmlogin.username.value=="" || Frmlogin.password.value==""){
alert("请正确输入用户名和密码");
return false;
}
else{
return true;
}
}
</script>
nbshiny 2004-06-07
  • 打赏
  • 举报
回复
这里的主要问题是我不知道当用户没有写用户名,密码的时候,怎么验证,怎么返回错误,难道要用到javascript?
nbshiny 2004-06-07
  • 打赏
  • 举报
回复
我给你看看现在的代码吧,我也是粗粗把两个页面的内容结合起来
<!--#include file="conn.asp"-->
<%
id = request("num")
password = request("passwd")


if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('请选择您的姓名');window.location.href='main.asp';</script>"///????/?原来是两个页面,所以用这句话
response.end
end if
if password = "" then
conn.close
set conn = nothing
response.write "<script>alert('请输入密码');window.location.href='main.asp';</script>"////??如何返回当前页面
response.end
end if



sql = "select * from student where num='"&id&"'"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.recordcount < 1 then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('学号输入错误,没有该学生');history.go(-1);</script>"
else
if password = rs("passwd") then

session("num") = rs("num")
rs.close
set rs = nothing
conn.close
set conn = nothing
'response.redirect "zytm1.asp"
response.write "<script>window.location.href='zytm1.asp';</script>"
else
rs.close
set rs = nothing
conn.close
set conn = nothing

response.write "<script>alert('密码错误');window.location.href='main.asp';</script>"
end if
end if
%>
<html>
<head>
<base target="rbottom">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>



<body background="images/bg.jpg">
<br>
<br><br><br><br><br><br><br>
<%
if session("num")="" then %>
<form method="post" action="main.asp" id=form1 name=form1>
<p align="left">                               学号:<input name="num"></p>
<p align="left">                               密码:<input type="password" name="passwd"> <A href="passwd.asp">修改密码</A> </p>
<p align="left">                                        <input type="submit" value="提交" name="B1"><input type="reset" value="重置" name="B2"></p>

</form>


<center>
  (注:用户名为学生学号,初始密码与学号相同,请登录后自行修改!)
</p></center>
<%else
sql = "select name from student where num='"&session("num")&"'"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<div align="center">欢迎  <font color=#FF0000 size=6><%=rs("name")%></font>  同学回来
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>

</div>

</body>
</html>
nbshiny 2004-06-07
  • 打赏
  • 举报
回复
呵呵,我原来是多做了一个页面,但是感觉不好,一个页面可以解决的问题干吗要两个页面
QCB181 2004-06-07
  • 打赏
  • 举报
回复
干吗要这样做呢,多做一个页面不就成了
zengting 2004-06-07
  • 打赏
  • 举报
回复
你自己贴出源码我们帮你修改不好吗?自己不先动脑,总是想要吃现成的,没前途。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧