View Full Version : log in
reubenb
10-01-2002, 02:49 AM
yo,
i made a simple asp login script that a user enters a username and pwd then the script sees if those details are in the sql mdb file. if it is it goes to 1 page .
now my problem is how do i make each usergo to a different page
say i wanted jsmith to go to http://www.whoolimewhat.com/checkme.asp
and rteeoff to go to http://~.com/help.asp
???
help soon please
thanky!
oracleguy
10-01-2002, 02:52 AM
You could add another field into your database that would store the appropriate redirect address. So then if the username and password is correct, it pulls the address out of the record and redirects it.
reubenb
10-01-2002, 02:56 AM
hey,
thanks for the reply...
could u give me please a sample of what you mean then i can like do it from there..
ta
oracleguy
10-01-2002, 03:03 AM
Okay for the example lets say your recordset object was named 'rs'. And the field that is holding the redirect information is called 'redirectlink'
So you do is replace the current redirect line with:
Response.Redirect(rs("redirectlink").value)
And remeber there can't be any html whatsoever before the redirect line.
reubenb
10-01-2002, 03:24 AM
yeah that doesn't work...
i made another column in my database...
called rl then added guest.asp to the value
then:
Sub CheckLogin
Dim Conn, cStr, sql, RS, username, userpwd
username = Request.Form("username")
userpwd = Request.Form("userpwd")
Set Conn = Server.CreateObject("ADODB.Connection")
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("\fpdb\pass.mdb") & ";"
Conn.Open(cStr)
sql = "select username from pass where username = '" & LCase(username) & "'"
sql = sql & " and userpwd = '" & LCase(userpwd) & "'"
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = "The username or password you specified is incorrect. Please try again."
ShowLogin
Else
Session("UserLoggedIn") = "true"
Response.Redirect(rl("redirectlink").value)
End If
End Sub
%>
Then it still doesnt work
help help help help
BigDaddy
10-01-2002, 03:45 AM
I noticed a couple of things:
Look at your SQL statement.
sql = "select username from pass where username = '" & LCase(username) & "'"
sql = sql & " and userpwd = '" & LCase(userpwd) & "'"
You're asking it to get the username and userpwd, but you don't appear to be asking it to get the field "rl".
Also, you're setting the value of your recordset to "RS", but in your redirect statement, you put "rl".
Try:
<%
Sub CheckLogin
Dim Conn, cStr, sql, RS, username, userpwd
username = Request.Form("username")
userpwd = Request.Form("userpwd")
Set Conn = Server.CreateObject("ADODB.Connection")
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("\fpdb\pass.mdb") & ";"
Conn.Open(cStr)
sql = "select * from pass where username = '" & LCase(username) & "' and userpwd = '" & LCase(userpwd) & "'"
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = "The username or password you specified is incorrect. Please try again."
ShowLogin
Else
Session("UserLoggedIn") = "true"
Response.Redirect(rs("rl"))
End If
End Sub
%>
reubenb
10-01-2002, 03:50 AM
oy! i cant believe i forgot that..
yea, thanks so much for reminding me the basics hehe :-D
thanks,! (it works by the way)
BigDaddy
10-01-2002, 03:51 AM
Cool.
reubenb
10-01-2002, 03:54 AM
hehehe we must be both at our computers sitting there waiting for the entries...
once again thanks for making my brain rememeber things.. :-D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.