Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 13th, 2005, 08:23 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
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
    Response.Redirect"unauthorised.asp"
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")
%>

</head>

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

</div>
</body>

----------- 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
Response.Redirect"unauthorised.asp"
%>


Reply With Quote
  #2 (permalink)  
Old July 13th, 2005, 12:52 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.

Cheers,

Imar
---------------------------------------
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?
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.