Presumably the type of each user will be stored in the database with the user-id and 
password.  That means that it's available for retrieval into the record set by adding 
the field to your SQL statement.

After that it's simply a matter of looking at the field and acting accordingly.

Your code does two things on successful log-in: it sets a session variable and it does 
a response.redirect to a new page.  Potentially you need to set an extra session 
variable, to differentiate between normal and admin, and also go to a different page.

Note however, that your response.redirect precedes your setting of the session 
variable.  Off the top of my head, that would mean that the session variable never 
actually gets set.

Dave S

  ----- Original Message ----- 
  From: nice guy 
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, July 21, 2004 11:51 AM
  Subject: Re: [ASP] LOGIN( need ideas)


  i want to know how to do a 2 level login for my login.........1 for admin.........1 
for normal users.............TQ

  Mark E <[EMAIL PROTECTED]> wrote:So what is your question?  Are you asking how to 
differentiate between admin and normal users?

  Also, if that is your actual database and server name, you may want to consider 
changing it when posting.  Just to be cautious : )

  Mark

  nice guy <[EMAIL PROTECTED]> wrote:


  hi guys...i want to do a 2 level Log- in page....(Admin and normal User) ...I am 
using SQL SERVER and ASP.

  below is my code for login..........

  <HTML><HEAD>
  <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
  <!--

  function form1_onsubmit() {
  if (form1.txtusername.value == "" || form1.txtpassword.value == "")
  return false;
  }

  //-->
  </SCRIPT>
  </HEAD>
  <BODY>
  <FORM action="ProcessLogin.asp" method=post 
  LANGUAGE=javascript onsubmit="return form1_onsubmit()">

  Username:
  <INPUT id=text1 name=txtusername size="20" >&nbsp;&nbsp;&nbsp;&nbsp;

  <p>Password:</b><INPUT type="password" name=txtpassword size="20" ></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


  <INPUT type="submit" value="Login" name="login"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <p>&nbsp;</p>
  </FORM>
  </BODY></HTML>

  ASP file:

  <title>CheckUser</title>
  <%
  'Dimension variables
  Dim adoCon   'Database Connection Variable
  Dim strCon  'Holds the Database driver and the path and name of the database
  Dim rsNew_User   'Database Recordset Variable
  Dim strSQLDB  'Holds the Access Database Name
  Dim strSQL   'Database query sring
  Dim strUser_Name  'Holds the user name

  'Initalise the strUserName variable
  strUserName = Request.Form("User_Name")

  'Check the database to see if user exist and read in the password

  strSQLDB = "ASFTS"

  'Create a connection odject
  Set adoCon = Server.CreateObject("ADODB.Connection")
      
  'Database connection info and driver
  strCon = "Provider=SQLOLEDB; Database=ASFTS; Server=mkzsa018.ap.infineon.com; User 
ID=; Password="

  'Set an active connection to the Connection object
  adoCon.Open strCon

  'Create a recordset object
  Set rsNew_User = Server.CreateObject("ADODB.Recordset")

  'Initalise the strSQL variable with an SQL statement to query the database
  strSQL = "SELECT New_User.User_Pass, New_User.User_Mail FROM New_User WHERE 
New_User.User_Name ='" & strUser_Name & "'"

  'Query the database
  rsNew_User.Open strSQL, strCon

  'If the recordset finds a record for the username entered then read in the password 
for the user
  If NOT rsNew_User.EOF Then

  'Read in the password for the user from the database

  If Request.Form("User_Pass") = rsNew_User("User_Pass") Then
    
  Response.Redirect "main2.htm" 
    
    'If the password is correct then set the session variable to True
    Session("blnIsUserGood") = True
    
    'Close Objects before redirecting
    Set adoCon = Nothing
    Set strCon = Nothing
    Set rsNew_User = Nothing
    
    End If


  End If
    
  'Close Objects
  Set adoCon = Nothing
  Set strCon = Nothing
  Set rsNew_User = Nothing

  'If the script is still running then the user must not be authorised
  Session("blnIsUserGood") = False

  'Redirect to the unautorised user page
  Response.Redirect"login.htm"
  %>

  thanks for all the help


  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.723 / Virus Database: 479 - Release Date: 19/07/04

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to