navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

question about checking a database for a user

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> question about checking a database for a user
Page: [1]
 
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
question about checking a database for a user - 7/5/2005 12:03:49   
I found this code on a webpage that was in some other garbled language or something and I can't quite figure it out, I basically have a form that queries a database if a user exists in it, if it does 'do this', if it doesnt 'do this' type of thing:

here is the code I am using:

<%
session("Uname")=""
mememail=request("mememail")
mempassword=request("mempassword")
if mememail<>"" and mempassword <> "" then
Set Conn = Server.CreateObject("ADODB.Connection")
dsn="driver={microsoft access driver (*.mdb)};dbq=" & _
server.mappath("members.mdb")
Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")
SQL="select * from memberinfo where memberemail='" & mememail & _
"' and memberpassword='" & mempassword & "'"
Rs.Open sql,Conn,1,3
If Rs.Recordcount<>0 then
   	session("Uname")=rs("mName")
End If
Rs.Close
Conn.Close
end if
if session("Uname")<>"" then
	response.redirect session("callfrom")
else
	response.redirect request("notfound.asp")

end if
%>
<%session("callfrom")=request("found.asp")
if session("Uname")="" then response.redirect("notfound.asp")%>
Hello world



---------------------------------------------
I get the following error:

Response object error 'ASP 0158 : 80004005'

Missing URL

/checkuser.asp, line 23

A URL is required.
---------------------------------------------
Not quite sure how this URL redirection session stuff works...maybe there is a different way to do this? Basically if the user is not found in the database I need it to go to the notfound.asp page......If they are found, then go to: found.asp


I found all of this on the following site:
http://mcu1.psu.ac.th/asp/authen/

< Message edited by AllenD -- 7/5/2005 12:13:55 >
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 16:01:21   
response.redirect request("notfound.asp")

should be :

response.redirect ("notfound.asp")

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 16:14:49   
Ok, that part works, at least I dont get an error, but even now if I put a username and password in my form that DOES exist I get my notfound.asp page, and I should be getting my found.asp page ?

(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 16:35:07   
I wouldnt rely on recordcount

SQL="select * from memberinfo where memberemail='" & mememail & _
"' and memberpassword='" & mempassword & "'"
Rs.Open sql,Conn,1,3
If Rs.Recordcount<>0 then
session("Uname")=rs("mName")
End If


use :
SQL="select mName from memberinfo where memberemail='" & mememail & _
"' and memberpassword='" & mempassword & "'"
Rs.Open sql,Conn,1,3
If NOT Rs.EOF then
session("Uname")=rs(0)
End If


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 17:08:58   
Ok, good idea, I did that, but still get my notfound.asp page even if there is a record that it should have found? I guess my other code isnt correct, I never got a good "tutorial" from the original site of how this thing works, now I have:

<%
session("Uname")=""
mememail=request("mememail")
mempassword=request("mempassword")
if mememail<>"" and mempassword <> "" then
Set Conn = Server.CreateObject("ADODB.Connection")
dsn="driver={microsoft access driver (*.mdb)};dbq=" & _
server.mappath("members.mdb")
Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")
SQL="select mName from memberinfo where memberemail='" & mememail & _ 
"' and memberpassword='" & mempassword & "'" 
Rs.Open sql,Conn,1,3 
If NOT Rs.EOF then 
session("Uname")=rs(0) 
End If 
Rs.Close
Conn.Close
end if
if session("Uname")<>"" then
	response.redirect session("callfrom")
else
	response.redirect ("notfound.asp")

end if
%>
<%'session("callfrom")=request("found.asp")
'if session("Uname")="" then response.redirect("notfound.asp")%>


(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 17:26:19   
Id then perform the normal troubleshooting to see if the variables are correct and populated and then if they exist in the database

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 17:31:36   
Ok, your right, I did not have the values identified correctly for the information that was being passed...Now I have the following error after making my corrections, never seen this one before?

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x11d4 Thread 0x9b8 DBC 0x8ddf024 Jet'.

/checkuser.asp, line 12

------------
My code is now:

<%
session("Uname")=""
mememail=request("memberemail")
mempassword=request("memberpassword")
'response.write mememail
'response.write mempassword
'response.end
if mememail<>"" and mempassword <> "" then
Set Conn = Server.CreateObject("ADODB.Connection")
dsn="driver={microsoft access driver (*.mdb)};dbq=" & _
server.mappath("members.mdb")
Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")
SQL="select mName from memberinfo where memberemail='" & mememail & _ 
"' and memberpassword='" & mempassword & "'" 
Rs.Open sql,Conn,1,3 
If NOT Rs.EOF then 
session("Uname")=rs(0) 
End If 
Rs.Close
Conn.Close
end if
if session("Uname")<>"" then
	response.redirect session("callfrom")
else
	response.redirect ("notfound.asp")
end if
%>
<%session("callfrom")=request("found.asp")
if session("Uname")="" then response.redirect("notfound.asp")%>

(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 17:34:46   
Id use an OLEDB connection (not ODBC), you also want to be checking the variables for ' characters too

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/5/2005 17:45:42   
I'm not sure I am familiar with OLEDB...Is the below code even close? Not sure what to change the ADODB.Connection part too. I tried... :)

Set Conn = Server.CreateObject("ADODB.Connection")
dsn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\members.mdb"
Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")

(in reply to Spooky)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 12:50:12   
Can anyone help me with the Query string's ?

(in reply to AllenD)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 14:57:26   
What error are you getting?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 15:05:22   
Microsoft JET Database Engine error '80004005'

Could not find file 'c:\members.mdb'.

/checkuser.asp, line 11


-------------------------

I am using a webhosting service from ipowerweb.com....So how do I know where the file is located on the server, c:, etc ?

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 15:10:05   
And you are sure that is where the database resides, at the root of C:?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 15:58:05   
No, I am not sure where it is...How do I find out?

(in reply to BeTheBall)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 17:08:53   
Ok, I got it working (kinda) by doing this:

dsn="Provider=Microsoft.Jet.OLEDB.4.0; Server.MapPath=members.mdb"

But if I enter a user that is in the database I get this error:

Microsoft JET Database Engine error '80004005'

Could not find installable ISAM.

/checkuser.asp, line 11

------
Anyone have any ideas on this?
Line 11 is Conn.Open dsn

(in reply to AllenD)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 17:24:26   
Try the modified version below:

dsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath=("members.mdb")

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 17:41:20   
That gives me this error:

Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment: 'Server.MapPath'

/checkuser.asp, line 10

(in reply to BeTheBall)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 18:23:03   
Woops, disregard this entry.

(in reply to AllenD)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 18:33:13   
Oops, the = after server.mappath is a typo. Should be:

dsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("members.mdb")


_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 18:40:25   
Getting closer! Now I get this error?

Microsoft JET Database Engine error '80004005'

Could not find file 'C:\Accounts\medicati\wwwRoot\members.mdb'.

/checkuser.asp, line 13


---
I verified the file is there, and I can open and see it. Is there a way for me to do it with FILEDSN = ?

I saw something like there here http://mavweb.net/asp-samples/database-connection-strings.asp but dont quite understand it.

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 19:04:22   

dsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("/members.mdb")

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 19:35:47   
Actually, I think you need to at least know where the database resides. Do you have a folder within your web that holds your dbs?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to BeTheBall)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 19:44:10   
Yep, changed that too:

dsn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("fpdb/members.mdb")

now I get this error:

Microsoft JET Database Engine error '80040e10'

No value given for one or more required parameters.

/checkuser.asp, line 15

Line 15 reads: Rs.Open sql,Conn,1,3

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 19:47:23   
At least that error is not related to the connection. :) Means you are making progress.

Now take this code:

Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")
SQL="select mName from memberinfo where memberemail='" & mememail & _
"' and memberpassword='" & mempassword & "'"
Rs.Open sql,Conn,1,3

change it to:

Conn.Open dsn
Set RS = Server.CreateObject("ADODB.Recordset")
SQL="select mName from memberinfo where memberemail='" & mememail & _
"' and memberpassword='" & mempassword & "'"
response.write SQL
response.end
Rs.Open sql,Conn,1,3

That will write out the SQL string and let you see what may be missing.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 20:04:08   
I got it...your right, the Mname was not valid, not sure why I had that in there, I changed it too, and it works! THANKS DUANE!

select * from from memberinfo where memberemail='" & mememail & _

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: question about checking a database for a user - 7/7/2005 20:08:31   
Glad you got it sorted out. Now you can enjoy what's left of your day.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to AllenD)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> question about checking a database for a user
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts