Authentication for web pages

Results 1 to 3 of 3

Thread: Authentication for web pages

  1. #1
    Aaron Senft Guest

    Default Authentication for web pages

    I tried to imnplement the Authentication scheme that is on this web page and kept running into problems. I am not sure if I am creating a database connection correctly and running a query against the information in the database. The way it looks, the information is being submitted to the database and not queried against the information. If anyone could help me out on this, I would greatly appreciate it. Thanks in advance!<BR><BR>Aaron Senft<BR>Development Consultants, Inc.

  2. #2
    Eric Veal Guest

    Default RE: Authentication for web pages

    I am trying to do something similar. I would like to create new password protected user accounts in an Access 2000 database. I want to have a form that requires a unique UserName and a password that is verified. How can I do this? Thanks.

  3. #3
    Join Date
    Dec 1969
    Posts
    78

    Default RE: Authentication for web pages

    This is the way that I do it (although not bullet proof). I have a database table that includes fields for a username and a password. The following code authenticates the user, assuming that he has a username and a password assigned in the database already :).<BR><BR><BR>&#060;% Response.Buffer = True %&#062;<BR>&#060;%<BR>StrPassword=Request.Form("Pa ssword")<BR>StrUserName=Request.Form("UserName")<B R><BR>IF StrUserName=NUL THEN<BR>StrQueryName="&#039Guest&#039"<BR>ELSE<BR> StrQueryName="&#039" & StrUserName & "&#039"<BR>END IF<BR><BR>myDSN="DSN=dsnname;"<BR>mySQL="SELECT * FROM GenInfo Where UserName = "<BR>mySQL=mySQL & StrQueryName<BR><BR>set connTemp=server.createobject("adodb.connection")<B R>connTemp.open myDSN<BR>set rsTemp=conntemp.execute(mysql)<BR><BR>IF NOT rsTemp.EOF THEN<BR>IF rsTemp("Password") = StrPassword then<BR>Session("UserName") = StrUserName<BR>response.redirect("nextpage.asp")<B R>END IF<BR>END IF<BR>%&#062;<BR><BR><BR>&#060;HTML&#062;<BR>&#060 ;HEAD&#062;<BR>&#060;TITLE&#062;Login Authentication&#060;/TITLE&#062;<BR>&#060;/HEAD&#062;<BR>&#060;BODY&#062;<BR>&#060;CENTER&#06 2;<BR>&#060;FORM ACTION="login.asp" METHOD=POST&#062;<BR>&#060;TABLE&#062;<BR>&#060;TR &#062;<BR>&#060;TD&#062;User Name&#060;/TD&#062;<BR>&#060;TD&#062;&#060;INPUT TYPE=TEXT NAME="UserName" Value="&#060;%=StrUserName%&#062;"&#062;&#060;/TD&#062;<BR>&#060;/TR&#062;<BR>&#060;TR&#062;<BR>&#060;TD&#062;Passwo rd&#060;/TD&#062;<BR>&#060;TD&#062;&#060;INPUT TYPE=Password NAME="Password"&#062;&#060;/TD&#062;<BR>&#060;/TR&#062;<BR>&#060;TR&#062;&#060;TD&#062;&#060;/TD&#062;<BR>&#060;TD&#062;&#060;INPUT TYPE=SUBMIT VALUE="Login"&#062;&#060;/TD&#062;<BR>&#060;/TR&#062;<BR>&#060;/FORM&#062;<BR>&#060;%<BR>rstemp.close<BR>conntemp. close<BR>set rstemp=nothing<BR>set conntemp=nothing<BR>%&#062;<BR>&#060;/TABLE&#062;<BR>&#060;/CENTER&#062;<BR>&#060;/BODY&#062;<BR>&#060;/HTML&#062;<BR><BR><BR><BR>Then at the top of every page that I want protected, I put at the very beginning of the code:<BR><BR><BR>&#060;%@ Language="VBScript" %&#062;<BR>&#060;% Response.Buffer=TRUE %&#062;<BR>&#060;%<BR>IF Session("UserName")=NUL THEN<BR>Response.Redirect("login.asp")<BR>END IF<BR>.<BR>.<BR>.<BR>%&#062;<BR><BR>I hope this answers your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •