Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Protected Web Page

Status
Not open for further replies.

xxLewisxx

Technical User
Apr 7, 2004
23
0
0
GB
Hi,

I got some code for putting a password on a web page from the FAQ section (thanks!) but I keep getting an error on line 12 of the code. Can any of you see where it's going wrong? Could it be becasue the rest of my pages aren't connected with the ado prefix? I've put my code below:

This is the form on the front page:

<Form method=post action=logindone.asp>
Username:
<input type="text" name="username">
<br>
Password:
<input type="password" name="password">
<br>
<br>
<input type="submit" value="Login">
</form>

This is the code it links to (line 12 is adoRS.Open SQL,adoConn) :

*logindone.asp*
<%
Username = Request.Form("USERNAME")
Password = Request.Form("PASSWORD")
'Get username and password from previous page

SQL = "SELECT * FROM Users Where Username='" & Username & "'"
set adoConn = Server.CreateObject ("ADODB.Connection")
set adoRS = Server.CreateObject ("ADODB.RecordSet")
dbPath = Server.MapPath("FinalProject.mdb")
adoConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
adoRS.Open SQL,adoConn
' OPen a DSN less connection to an access database and get the username and password for the record where username=username

If adoRS.EOF Then
'The username doesn't exist, do an error.
Response.Write "Username Doesn't Exist!"
Else
If Trim(Password) = Trim(adoRS("Password")) Then
'If the passwords match
Session("LoggedIn")="TRUE"
'Set a session variable to true
%>
<SCRIPT LANGUAGE=VBSCRIPT>
window.navigate "staffhome.html"
</SCRIPT>
<%
'Forward user to next page
Else
'Passwords don't match
Response.Write "Password is incorrect"
End If
End IF
set adoRS = Nothing
set adoConn = Nothing
%>

Thanks in advance...

Lx
 
what is the error that is being reported?


Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
I've done it!!

The problem was with the SQL statement not line 12 as the error message was saying.

Thanks anyway.

Lx
 
I think it was reference wrong!

Thanks again.

Lx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top