Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 13th, 2005, 08:23 AM
Authorized User
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default login script

Would someone please help me with this login script! ASAP...

---------- authorised.asp

'If the session variable is False or does not exsist then redirect the user to the unauthorised
If Session("ValidateUser") = False or IsNull(Session("ValidateUser")) = True then
    'Redirect to unauthorised
End If
'Dimension Variables
Dim strUserName 'Holds the name of the user

'Get the users name passed from the previous page
strUserName = Request.QueryString("name")


<body bgcolor="green" text="black">
<table width="518" border="0" cellspacing="0" cellpadding="0" align="center">
    <td align="center">
      <h1>Authorised Access</h1>
<div align="center">
    Welcome <b>
    <% =strUserName %>
    </b> to the password proteceted area of the web site. </p>


----------- validateuser.asp
'Dimension variables
Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim rsCheckUser 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim strUserName 'Holds the user name

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

'Check the database to see if user exsits and read in there password
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "users"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath(strAccessDB)

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

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

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblUsers.Password FROM tblUsers WHERE tblUsers.UserID ='" & strUserName & "'"

'Query the database
rsCheckUser.Open strSQL, strCon

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

    'Read in the password for the user from the database
    If (Request.Form("txtUserPass")) = rsCheckUser("Password") Then

        'If the password is correct then set the session variable to True
        Session("validateuser") = True

        'Close Objects before redirecting
        Set adoCon = Nothing
        Set strCon = Nothing
        Set rsCheckUser = Nothing

        'Redirect to the authorised and send the users name
        Response.Redirect"authorised.asp?name=" & strUserName
    End If
End If

'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsCheckUser = Nothing

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

'Redirect to the unautorised

Old July 13th, 2005, 12:52 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi jstewie,

I am sure there are many people on this forum willing to help you. However, there are a few things wrong with your post that minimize your chances on an answer:

First of, you're posting this in a JavaScript forum while your code seems to be dealing with ASP VB Script. Maybe you do, but I don't see the connection.

Secondly, you post a lot of code without any indication of problematic lines or something like that.

But finally, and that makes it impossible to answer this, you don't tell us what the problem is. You don't describe the problem, errors or general expected behavior of the page at all. You don't expect us to get this code, save it somewhere, try to recreate your scenario, create a new database based on the SELECT statements in the code and then try to figure out the problem, do you???

I suggest you read How To Ask Questions The Smart Way. I am sure you'll find it an enlighting article to read. Then come back to p2p.wrox.com, select the proper forum, and ask a question the smart way.


Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Avon by Queens of the Stone Age (Track 2 from the album: Queens of the Stone Age) What's This?

Similar Threads
Thread Thread Starter Forum Replies Last Post
having a problem with login script dbwieler PHP Databases 1 November 14th, 2007 02:12 AM
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
login script Apocolypse2005 Javascript 3 June 24th, 2005 04:07 PM
login script problem hosefo81 PHP How-To 9 August 20th, 2004 11:28 AM
Login Script natmaster PHP How-To 10 June 19th, 2003 03:50 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.