473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Need help with ASP script.

Hello everyone I have a question. The school I am working for is in
the beginning process of having a webpage that will direct students to
download there homework and be able to view there info like test
scores and etc(the homework and info page will reside on our
webservers at the school on the local intranet network). Now what I
need is a way for the students to go to a login page and when logging
in will be automatically directed to there own personal index.htm page
that will reside in a folder containing all there information and
homework. I had downloaded a free ASP script which basically uses a
Access DB to authorize the username and password and gives 2 diffrent
asp result pages either "Granted" or "No Access". Now the only thing I
can think of is to put a script in each students virtual directory and
when getting to there index file have this script run and the results
will let them in or give them no access but I think that would be way
to much. So what do you guys recommend and is there any links you know
that I can get some info from?
Here is the code from the free code I got
-----------------------------------------------------------------------
<%
'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("blnIsUserGood") = True

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

'Redirect to the authorised user page and send the users name
Response.Redirect"authorised_user_page.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("blnIsUserGood") = False

'Redirect to the unautorised user page
Response.Redirect"unauthorised_user_page.htm"
%>
-----------------------------------------------------------------------------
Any help would be appreciated.
Jul 21 '05 #1
2 1910
First a nitpick, "there" is used to indicate a location. When talking about
something belonging to a person you use "their".

Actually the approach you mention does not go far enough. Every single page
that you want to protect must include code to verify that the student is
logged on.

1. create a logon page that is shared by everyone
2. when a student logs on set a session variable or temporary cookie
indicating that they are logged on. For example: Session("studentid") =
<whatever student id is in the database>
3. redirect the logged on student to their home page. If all of the student
data is in a database then this page can be built dynamically using a single
ASP page.
4. on all pages that require a student to be logged on (including the home
page) check that the session variable or cookie exists. If it does not then
re-direct them to the login page.

If Len(Session("studentid")) = 0 Then
response.redirect "login.asp"
End If

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

"Bobby" <de*****@hotmail.com> wrote in message
news:d0*************************@posting.google.co m...
Hello everyone I have a question. The school I am working for is in
the beginning process of having a webpage that will direct students to
download there homework and be able to view there info like test
scores and etc(the homework and info page will reside on our
webservers at the school on the local intranet network). Now what I
need is a way for the students to go to a login page and when logging
in will be automatically directed to there own personal index.htm page
that will reside in a folder containing all there information and
homework. I had downloaded a free ASP script which basically uses a
Access DB to authorize the username and password and gives 2 diffrent
asp result pages either "Granted" or "No Access". Now the only thing I
can think of is to put a script in each students virtual directory and
when getting to there index file have this script run and the results
will let them in or give them no access but I think that would be way
to much. So what do you guys recommend and is there any links you know
that I can get some info from?
Here is the code from the free code I got
-----------------------------------------------------------------------
<%
'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("blnIsUserGood") = True

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

'Redirect to the authorised user page and send the users name
Response.Redirect"authorised_user_page.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("blnIsUserGood") = False

'Redirect to the unautorised user page
Response.Redirect"unauthorised_user_page.htm"
%>
-----------------------------------------------------------------------------
Any help would be appreciated.

Jul 21 '05 #2
On 9 Nov 2004 20:33:57 -0800, de*****@hotmail.com (Bobby) wrote:
Hello everyone I have a question. The school I am working for is in
the beginning process of having a webpage that will direct students to
download there homework and be able to view there info like test
scores and etc(the homework and info page will reside on our
webservers at the school on the local intranet network). Now what I
need is a way for the students to go to a login page and when logging
in will be automatically directed to there own personal index.htm page
that will reside in a folder containing all there information and
homework. I had downloaded a free ASP script which basically uses a
Access DB to authorize the username and password and gives 2 diffrent
asp result pages either "Granted" or "No Access". Now the only thing I
can think of is to put a script in each students virtual directory and
when getting to there index file have this script run and the results
will let them in or give them no access but I think that would be way
to much. So what do you guys recommend and is there any links you know
that I can get some info from?


1) There are already commercial apps written to do these things, or
at worst, portal apps available free.

2) Providing this type of access in a school environment without a
good handle on the security aspect is foolhardy.

3) If you're asking this question as you've asked it, you don't meet
the criteria for #2

Use Windows accounts and Windows Integrated security, redirect and
allow access based on the user ID, using
Request.ServerVariables("LOGON_USER").

Jeff
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its...
5
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
28
by: Randy Starkey | last post by:
Hi, Does anyone know where I can get a script that show a little plus sign after a line of text, that when you click the plus sign, more text is revealed on that same page, like a continuing...
5
by: news | last post by:
I have a new situation I'm facing and could use a suggestion or two, as I don't seem to be able to think in the abstract very well. We have a local server which holds all of our image files. We...
2
by: ern | last post by:
My command-line application must be able to run text scripts (macros). The scripts have commands, comments, and flags. Comments are ignored (maybe they are any line beginning with " ; ") Commands...
4
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*,...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
14
by: mistral | last post by:
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows.
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.