读书人

登陆有关问题 急

发布时间: 2012-02-11 09:51:35 作者: rapoo

登陆问题 急!急!急!急!急!急!
login.asp的代码:

<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> login </title>
<link href= "css/style.css " rel= "stylesheet " type= "text/css " /> <style type= "text/css ">
body {
margin-top: 150px;
}
</style>
</head>

<body>
<form name= "loginform " action= "checkuser.asp " method= "post ">
<table width= "333 " height= "216 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td background= "image/daohangbeijing.gif "> <table width= "333 " height= "261 " border= "0 " cellpadding= "0 " cellspacing= "0 " align= "center ">
<tr>
<td height= "106 "> <table width= "333 " height= "106 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "80 ">   </td>
</tr>
<tr>
<td height= "26 " align= "center " valign= "bottom " class= "ziti-bai ">          如果您是本站会员,请在此登陆! </td>
</tr>
</table> </td>
</tr>
<tr>
<td height= "155 " align= "center " valign= "top "> <table width= "200 " height= "130 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "110 " colspan= "4 " align= "right " valign= "top "> <table width= "160 " height= "75 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "50 " height= "25 " align= "right " class= "ziti-bai "> 用户名: </td>


<td align= "left ">
<label>
<input name= "username " type= "text " class= "input3 " />
</label> </td>
</tr>
<tr>
<td width= "50 " height= "25 " align= "right " class= "ziti-bai "> 密码: </td>
<td align= "left "> <input name= "password " type= "password " class= "input3 " /> </td>
</tr>
<tr>
<td width= "50 " height= "25 " align= "right " class= "ziti-bai "> 验证码: </td>
<td align= "left "> <input name= "validatecode " type= "text " class= "input4 " />   <img src= "include/validatecode.asp "> </td>
</tr>
</table>
<table width= "160 " height= "35 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "40 " align= "center "> <table width= "150 " height= "30 " border= "0 " cellpadding= "0 " cellspacing= "0 ">


<tr>
<td align= "center " class= "ziti "> <input onClick= "return check(); " type= "image " value= "botton " src= "image/daohanglogin.gif " width= "150 " height= "30 "> </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
<tr>
<td width= "40 " height= "20 " align= "right " class= "ziti ">   </td>
<td width= "60 " align= "left " valign= "bottom " class= "ziti "> <a href= "members/user_reg.asp " class= "ziti-bai "> <font color= "#FFFFFF "> 用户注册 </font> </a> </td>
<td width= "90 " align= "right " valign= "bottom " class= "ziti "> <a href= "# " class= "ziti-bai "> <font color= "#FFFFFF "> 找回密码 </font> </a> </td>
<td width= "10 " align= "right " class= "ziti ">   </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
</table>
</form>
</body>
</html>
<script LANGUAGE= "javascript ">
<!--
function checkspace(checkstr) {
var str = ' ';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}


function check()
{
if(checkspace(document.loginform.username.value)) {
document.loginform.username.focus();
alert( "用户名不能为空! ");
return false;
}
if(checkspace(document.loginform.password.value)) {
document.loginform.password.focus();
alert( "密码不能为空! ");
return false;
}
if(checkspace(document.loginform.validatecode.value)) {
document.loginform.validatecode.focus();
alert( "验证码不能为空! ");
return false;
}
document.loginform.submit();
}

document.loginform.username.focus();
//-->
</script>

checkuser.asp的代码

<!--#include file = "include/conn.asp "-->
<!--#include file = "include/md5.asp "-->
<!--#include file = "include/config.asp "-->
<%
if NOT isempty(request( "LoginSubmit ")) then
dim username,password,passcode

username = checkStr(trim(Request.Form( "username ")))
password = md5(checkStr(trim(Request.Form( "password "))))
passcode = checkStr(trim(Request.Form( "passcode ")))

if username= " " or password= " " then
call MsgBox( "对不起,登录失败,请检查您的登录名和密码 ", "none ", "None ")
end if

if not isnumeric(validatecode) then
call msgbox( "登录失败!验证码必须是数字,请正确填写! ", "none ", "none ")
end if

if Trim(Session( "wwwtoot.com_ValidateCode ")) <> Trim(Request.Form( "validatecode ")) then
call msgbox( "登录失败!验证码错误! ", "back ", "none ")
end if

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

SQL= "select * from [table_user] where username= ' "&username& " ' and password= ' "&password& " ' "
rs.open sql,conn,1,3

if not(rs.bof and rs.eof) then
if password=rs( "password ") then
session( "userid ") = trim(rs( "userid "))
session( "username ") = trim(rs( "username "))
if rs( "vip ") = "yes " then
rs( "lastvst ")=now()
rs( "loginnum ")=rs( "loginnum ")+1
rs.Update
rs.Close
set rs=nothing
response.redirect "myinfo.asp "
else
rs( "lastvst ")=now()
rs( "loginnum ")=rs( "loginnum ")+1
rs.Update
rs.Close
set rs=nothing
response.redirect "index.asp "
End if


else
call MsgBox( "对不起,您的用户名或密码有误! ", "Back ", "None ")


end if
else
call MsgBox( "对不起,您的用户名或密码有误! ", "Back ", "None ")
end if

end if


%>

希望vip用户登陆到myinfo.asp 普通用户登陆到index.asp

这有什么问题啊 怎么我在数据库里添加了一个用户 在登陆叶面却无法登陆到index.asp呢

[解决办法]
看了,代码没问题,不过记得在if、else、end if的时候加上response.end如:

if username= " " or password= " " then
call MsgBox( "对不起,登录失败,请检查您的登录名和密码 ", "none ", "None ")
response.end
end if

if not isnumeric(validatecode) then
call msgbox( "登录失败!验证码必须是数字,请正确填写! ", "none ", "none ")
response.end
end if
.....后面的还有
如果问题还没得到解决,很有可能是数据库更新的问题,建议先测试数据库更新代码
rs.update

读书人网 >ASP

热点推荐