If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > how to redirect page

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-18-04, 23:47
newbieasp newbieasp is offline
Registered User
 
Join Date: Oct 2004
Posts: 43
how to redirect page

how do you redirect from a login page according to security level in access. I have my login page which checks for valid username and password, but how would you redirect according to a number in my access database. Here is code from page:

<%
'here is the connection string
'Set conn = server.createobject("adodb.connection")
Set adoCon = Server.CreateObject("ADODB.Connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
'DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("login.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("wwwroot/login.mdb")
adoCon.Open "DSN=Employees"
'conn.Open DSNtemp
Set rsEmployees = Server.CreateObject("ADODB.Recordset")

'here we are getting the info from the login form
If InStr(Request.Form("uid"),"'") Then
uid = Replace(Request.Form("uid"),"'"," ")
Else
uid = Request.Form("uid")
End If
If InStr(Request.Form("pwd"),"'") Then
pwd = Replace(Request.Form("pwd"),"'"," ")
Else
pwd = Request.Form("pwd")
End If

'now we will querry the database for a match
strSQL = "Select * From users Where uid = '" & uid & "' And pwd = '" & pwd & "'"
rsEmployees.Open strSQL, adoCon

'if the user is found we will set the session okeydokey to TRUE allowing the user to gain entrance
If Not rsEmployees.EOF Then
session("login") = "TRUE"
session("loanofficer") = rsemployees("loanofficer")

'always always always destroy recordsets and close connections!
Set rsEmployees = Nothing
Set rsEmployees= Nothing
Set adoCon = Nothing

'since the user was found, we sent them toodling on to the next page
'################################################# ################################################## #####
'##### IN THE LINE BELOW CHANGE INDEX2.ASP TO THE PAGE YOU WANT THE USERS TO BE DIRECTED TO
Response.Redirect "search_form.asp"
Else

'ooops if we got this far they dont know their login info or arent in the database
'AGAIN always always always destroy recordsets and close connections!
Set rsEmployees = Nothing
Conn.Close
'so we send em back to try again
Response.Redirect "index.asp"


End If
%>


something like

If blank = rs("field') then
redirect blah.asp
Reply With Quote
  #2 (permalink)  
Old 10-19-04, 00:05
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
do you mean something like this...?
Code:
<%
Set adoCon = Server.CreateObject("ADODB.Connection")
Server.Mappath("wwwroot/login.mdb")
adoCon.Open "DSN=Employees"
Set rsEmployees = Server.CreateObject("ADODB.Recordset")

If InStr(Request.Form("uid"),"'") Then
  uid = Replace(Request.Form("uid"),"'"," ")
Else
  uid = Request.Form("uid")
End If

If InStr(Request.Form("pwd"),"'") Then
  pwd = Replace(Request.Form("pwd"),"'"," ")
Else
  pwd = Request.Form("pwd")
End If

'now we will querry the database for a match
strSQL = "Select * From users Where uid = '" & uid & "' And pwd = '" & pwd & "'"
rsEmployees.Open strSQL, adoCon

If Not rsEmployees.EOF Then
  session("login") = "TRUE"
  session("loanofficer") = rsemployees("loanofficer")
  session("blank") = rsEmployees("field")

  'always always always destroy recordsets and close connections!
  Set rsEmployees = Nothing
  Set rsEmployees= Nothing
  Set adoCon = Nothing
  
  if session("blank") = 1 then
    Response.Redirect "search_form.asp"
  else if session("blank") = 3 then
    Response.Redirect "search_form3.asp"
  else
    Response.Redirect "search_form6.asp"
  end if

Else
  Set rsEmployees = Nothing
  adoCon.Close
'so we send em back to try again 
Response.Redirect "index.asp"


End If
%>
Reply With Quote
  #3 (permalink)  
Old 10-19-04, 00:13
newbieasp newbieasp is offline
Registered User
 
Join Date: Oct 2004
Posts: 43
thats what I am looking for. I tried the code but get the error:

Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/database/check.asp, line 43
Else
Reply With Quote
  #4 (permalink)  
Old 10-19-04, 00:16
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
sorry,
Code:
  if session("blank") = 1 then
    Response.Redirect "search_form.asp"
  elseif session("blank") = 3 then
    Response.Redirect "search_form3.asp"
  else
    Response.Redirect "search_form6.asp"
  end if
you could also use a select case statement which might look nicer...
Reply With Quote
  #5 (permalink)  
Old 10-19-04, 00:32
newbieasp newbieasp is offline
Registered User
 
Join Date: Oct 2004
Posts: 43
worked thanks once again
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On