PDA

View Full Version : Login problems


Mister B.
07-02-03, 05:00 PM
Hi, this is my first time on these forums, I hope you guys can help me out.


this is code from the login page:

<FORM name="formchecker" METHOD="POST" onSubmit="return Allfull(this)" ACTION="/sagaofchaos/loginreact.asp">
Username : <INPUT TYPE="text" Name="username" class=FormControls>
Password : <INPUT TYPE="password" Name="pssword" class=FormControls>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="LOGIN" class=FormControls2>
<SCRIPT LANGUAGE=JAVASCRIPT>
function Allfull(theform)
{
if ((theform.username.value == "") || (theform.pssword.value == "")) {
alert("Please enter a username and a password.");
return (false);
}
else { return (true); }
}



this is the code from the loginreact page:

<%'Option Explicit%>
<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
Dim connstr
connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/sagaofchaos/db/users.mdb")& ";PWD=pssword;"
set RS = server.CreateObject("ADODB.Recordset")
conn.Open connstr
Dim rs, strSQL, i
strSQL = "SELECT * FROM users WHERE username = '" & Request("username") & "'"
RS.open "users", Conn, 2, 3
If Not RS.EOF Then
IF RS("pssword") = Request("pssword") Then %>
Login succesfull.
<A HREF="http://WWW.sagaofchaos.tk">Click here to return home</a>
<%
Response.Cookies("sagaofchaos")("user") = rs("username")
Response.Cookies("sagaofchaos")("admin") = rs("admin")
%>
<% ELSE %>
Login Failed
<A HREF="http://WWW.sagaofchaos.tk">Click here to return home</a>
<% End If %>
<% ELSE %>
Login Failed
<A HREF="http://WWW.sagaofchaos.tk">Click here to return home</a>
<% End If %>

for some reason whether or not you use the right username and password, this site always returns Login Failed, except for the newest member, can anyone tell me why?

Stealth
07-02-03, 06:30 PM
Try:


<%
Set conn = Server.CreateObject("ADODB.Connection")

connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/sagaofchaos/db/users.mdb")& ";PWD=pssword;"

set RS = server.CreateObject("ADODB.Recordset")
conn.Open connstr

strSQL = "SELECT * FROM users WHERE username='"&Request("username")&"' and pssword='"&Request("pssword")&"'"
RS.open "users", Conn, 2, 3

if RS.bof or rs.eof then
response.write "Login Failed<br><A HREF=""http://WWW.sagaofchaos.tk"">Click here to return home</a>"
else
Response.write "<A HREF=""http://WWW.sagaofchaos.tk"">Click here to return home</a>"

Response.Cookies("sagaofchaos")("user") = rs("username")
Response.Cookies("sagaofchaos")("admin") = rs("admin")
End If
%>

Mister B.
07-02-03, 09:08 PM
Thanks alot! that got it.
:p

Stealth
07-02-03, 10:06 PM
no problem

hth

Mister B.
08-22-03, 02:12 PM
<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/cubularrpg/db/users2.mdb")& ";PWD=passwod;"
set RS = server.CreateObject("ADODB.Recordset")
conn.Open connstr
strSQL = "SELECT * FROM users WHERE Username='"&Request("username")&"' and Pssword='"&Request("pssword")&"'"
RS.open "users", Conn, 2, 3

if RS.bof or rs.eof then
response.write "Login Failed<br><A HREF=""http://WWW.sagaofchaos.tk"">Click here to return home</a>"
else
Response.write "<A HREF=""http://WWW.sagaofchaos.tk"">Click here to return home</a>"

Response.Cookies("cubularrpg")("user") = rs("username")

End If
%>

this is the code I am using, but for some reason it always says that it is right.

Shane
08-22-03, 02:17 PM
I always just used

if RS.EOF Then
' Login failed

Else
' Good login here

End IF


(i.e. without the rs.bof)

Stealth
08-22-03, 05:51 PM
ah, i use rs.bof ... force of habit lol

shouldnt make much of a difference tho?

Mister B.
08-23-03, 02:12 PM
Yeah I don't think that should be it...

Shane
08-23-03, 02:41 PM
I'm not familiar with the ADODB.Recordset object way, but are you actually executing your SQL statement?

I typically do:


strSQL = "select statement here"

Set RS = conn.Execute(strSQL)

If RS.EOF Then
' Not correct
Else
' correct
End If

Mister B.
08-23-03, 04:06 PM
Okay, sorry, but I have changed so much that I have to repost, a<!--#include file="adovbs.inc"-->
<HTML>
<HEAD>
<TITLE>Signing UP</TITLE>
</HEAD>
<BODY>
<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/cubularrpg/db/users.mdb")& ";PWD=password;"
set RS = server.CreateObject("ADODB.Recordset")
conn.Open connstr
strSQL = "SELECT * FROM users WHERE uname='"&Request("uname")&"' and upass='"&Request("upass")&"'"
RS.open "users", Conn, 2, 3
if RS.bof or rs.eof then
%>
Login Failed
<%
else
%>
Login Succesfull
<%
End If
%>

Shane
08-23-03, 04:35 PM
ok, but still, it doesn't look like you are excuting your sql statement.

Mister B.
08-24-03, 07:37 PM
some days you know


just changed "users" to strSQL and it is a dream!