Forum Moderators: open

Message Too Old, No Replies

if (server variable) = (item in a db column) then open page else

help with if then else statements and server variables

         

JillGuttu

6:35 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



I may have missed a topic on this already posted.. sorry if this is a repeat. I am trying to open a page to remind a user to register for my site if they have not already done so. I am capturing the logon name (server variable) successfully and inserting into a db along with some other info when they fill out this registration form. So, when a user enters my site, i want to be able to say - if this logon name equals a name already in my db, then direct the user to the home page. Otherwise, if it does not match, meaning the user has not filled out the registration form, then direct the user to a registration form page.

Here is what i'm starting with:

(to capture logon name)
<%
Dim sDomain
Dim sLogonUser
Dim sUserName

sLogonUser = Request.ServerVariables("AUTH_USER")
sDomain = Left(sLogonUser, InStr(1, sLogonUser, "\", vbTextCompare) -1)
sUserName = Right(sLogonUser, Len(sLogonUser) - InStr(1, sLogonUser, "\", vbTextCompare))

'sDomain = Mid(sLogonUser, 1, Len(sLogonUser) - InStr(1, sLogonUser, "\", vbTextCompare) + 1)
'sUserName = Mid(sLogonUser, InStr(1, sLogonUser, "\") + 1)
%>

(to open the db)
<%
dim oRSst
dim strSQL
Dim Conn
Dim ConnStr
Dim uSQL

Set conn = Server.CreateObject("ADODB.Connection") ' Create your connection object
connStr = "DSN=NHO; uid=orientation; pwd=nHouser01" ' Get database path
Conn.Open connStr ' Open the connection to the database

strSQL = "Select * From quizname Where uid = ('" & sUserName & "') ORDER BY date DESC"

%>

<%
Set oRSst = Server.CreateObject("ADODB.Recordset") 'Create your recordset object
oRSst.Open strSQL,Conn 'Open the recordset
%>

(to close the db)
<%
oRSst.Close ' Lets close the recordset object
Conn.Close ' Lets close the connection object
' Clear the variables
Set oRSst=Nothing
Set Conn=Nothing
%>

i just need help with the meat inside. Thanks in advance!

le_gber

6:42 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't understand how you sort out the member to the non member?

Leo

JillGuttu

6:46 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



well, on first visit, no one would have registered yet. So, i guess i'll look in the db and the username (logon name) won't exist so i redirect everyone to the registration form page. After that, if a user comes to the site who has already filled out the registration form, their username (logon name) will be in the db - i don't want them to have to see or fill out the reg. form again.

le_gber

6:52 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, so your site will only be accessed by members?

The index page will just be a login page?

So if they are member you go in, if you are not you go to the registration.

Is that right?

Leo

JillGuttu

6:57 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



exactly.

le_gber

7:00 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok then, I've got a really nice tutorial for you :)

Sorry I almost only use UltraDev to create asp pages, I know how to tweak code to my liking but that's it.

I sticky mail you the URL.

Leo

JillGuttu

7:16 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Thanks so much, leo. i'll check this out.

aspdaddy

9:49 am on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You just need a test to see if the recordset is empty:

if ( oRSst.eof )then
' not a member
' server.transfer "register.asp"
else
' existing member
' server.transfer "login.asp"
end if

I guess you know that if the site is set for anonymous web access then AUTH_USER is not available.