I have to come up with a user authenication page the logs the user in and also gives them access to do the right things. without using server side scripting. Just javacript and access. I have attached the code and the access file and have got started on a few things.
I first need to create a login page with the fields username and password have that check the access database and then proceed it to a page to do the following depending on the user access. For The Login button to even be enabled the username and password must have a value in it; I have no idea how to do that
Add A User [No duplicate Users]
Modify A User
- Admin can change anyone
- Power User can change only themselves
and everyone else except admin
- regular user can only change themselves
Delete A User
-Admin can delete anyone
Password Length [9-20 Characters]
Display The current person logged in person's info
Display all users
Groups:
Administrative - Has the ability to change everything
Power - Can change/modify everyone's informantion EXCEPT administrative group people
Regular - Can modify themselves only.
Only administrator and power user should be able to add a user
Only admin can delete users
Again it's supposed to connect with Access database and need to use javascript. I attached the file and code. Access 2007 File Thanks =).
HTML Page - <html>
-
<head>
-
<title>JavaScript Example 2</title>
-
<script type="text/javascript" src="JScriptDB.js">
-
-
</script>
-
</head>
-
<body>
-
-
<form name="student" method="get" action="" onSubmit="return false;">
-
-
<p>Enter student's first name: <input type="text" name="studentfn" /><br />
-
Enter student's last name: <input type="text" name="studentln" /><br />
-
Enter student's ID: <input type="text" name="studentid" /><br />
-
User Name: <input type="text" name="usr1" id="usr1" /><br/>
-
Password*: <input type="password" name="pswd1" id="pswd1" /><br />
-
Date Of Birhth: <input type="text" name="dob1" id="dob1" /><br/>
-
</p>
-
<p>
-
<input type="button" id="Display" onClick="Display()" value="Display All Records" />
-
<input type="button" id="Update" onClick="updateStudent()" value="Update Student" />
-
<input type="button" id="Delete" onClick="deleteStudent()" value="Delete Record" />
-
<input type="button" id="Insert" onClick="insertStudent()" value="Insert Record" />
-
<input type="button" id="Display" onClick="DisplayUser()" value="Display User Record" />
-
</p>
-
-
</form>
-
-
</body>
-
</html>
-
Javascript - //declare variables
-
-
var adOpenDynamic =2;
-
var adLockOptimistic =3;
-
var strDB_Path = "C:\Temp\\cst2309.accdb"; //MS access db path
-
var conn_str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strDB_Path; // MS 2007 Provider String
-
-
var conn_str11 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDB_Path; // MS 2003 Provider String
-
-
-
function AdoDB(strADO)
-
{
-
if(window.ActiveXObject)
-
{
-
return new ActiveXObject(strADO);
-
}
-
else
-
{
-
return ActiveXObject(strADO);
-
}
-
}
-
-
function DisplayUser()
-
{
-
var conn = AdoDB("ADODB.Connection");
-
var strSQL = "Select * from Student where usr ='"+ usr1 + "' and pswd = '"+ pswd1 +"'";
-
-
conn.open(conn_str,"",""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
var strHTML ="";
-
strHTML ="<table cellpadding=0 cellspacing=0 border=1 width='100%' align=center>";
-
strHTML +="<tr><td align=center colspan=4><b>Student Records</b></td></tr>";
-
-
if(!dsStudent.bof)
-
{
-
dsStudent.MoveFirst();
-
while(!dsStudent.eof)
-
{
-
strHTML += "<tr>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(0) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(1) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(2) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(3) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(4) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(5) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(6) +"</font></td>";
-
strHTML += "</tr>";
-
dsStudent.MoveNext();
-
}//close while
-
}// close if statement
-
else
-
{
-
strHTML += "<tr colspan=4><td align=center><font color=red>No Records :(</font></td></tr>";
-
}//close else
-
strHTML = "</table>";
-
document.write(strHTML);
-
}// close Display
-
-
function Display()
-
{
-
var conn = AdoDB("ADODB.Connection");
-
var strSQL = "Select * from Student";
-
-
conn.open(conn_str,"",""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
var strHTML ="";
-
strHTML ="<table cellpadding=0 cellspacing=0 border=1 width='100%' align=center>";
-
strHTML +="<tr><td align=center colspan=4><b>Student Records</b></td></tr>";
-
-
if(!dsStudent.bof)
-
{
-
dsStudent.MoveFirst();
-
while(!dsStudent.eof)
-
{
-
strHTML += "<tr>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(0) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(1) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(2) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(3) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(4) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(5) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(6) +"</font></td>";
-
strHTML += "</tr>";
-
dsStudent.MoveNext();
-
}//close while
-
}// close if statement
-
else
-
{
-
strHTML += "<tr colspan=4><td align=center><font color=red>No Records :(</font></td></tr>";
-
}//close else
-
strHTML = "</table>";
-
document.write(strHTML);
-
}// close Display
-
-
-
function updateStudent() {
-
var fn = document.getElementById("studentfn").value;
-
var ln = document.getElementById("studentln").value;
-
var studid = document.getElementById("studentid").value;
-
-
var strSQL = "update Student set fname = '" + fn + "' ,lname ='" + ln + "' where studentid =" + studid;
-
alert("SQL statement: " + strSQL);
-
-
var conn = AdoDB("ADODB.Connection");
-
-
conn.open(conn_str,"",""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
alert("updated completed");
-
}// close updateStudent
-
-
function deleteStudent()
-
{
-
// var fn = document.getElementById("studentfn").value;
-
// var ln = document.getElementById("studentln").value;
-
var studid = document.getElementById("studentid").value;
-
-
var strSQL = "delete Student where studentid =" + studid;
-
alert("SQL statement: " + strSQL);
-
-
var conn = AdoDB("ADODB.Connection");
-
-
conn.open(conn_str, "", ""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
alert("deleted completed");
-
-
}// close deleteStudent
-
-
function insertStudent()
-
{
-
var fn = document.getElementById("studentfn").value;
-
var ln = document.getElementById("studentln").value;
-
var studid = document.getElementById("studentid").value;
-
var dobv = document.getElementById("dob1").value;
-
-
var strSQL = "insert into Student(fname, lname,dob) values('" + fn + "','" + ln + "','" + dobv +"')";
-
alert("SQL statement: " + strSQL);
-
-
var conn = AdoDB("ADODB.Connection");
-
-
conn.open(conn_str, "", ""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
alert("insert completed");
-
}// close insertStudent
-
-
function LoginPerson()
-
{
-
-
var conn = AdoDB("ADODB.Connection");
-
var strSQL = "Select * from Student where usr ='"+ usr1 + "' and pswd = '"+ pswd1 +"'";
-
-
conn.open(conn_str,"",""); //open my db connection
-
-
// declare my dataset
-
var dsStudent = new ActiveXObject("ADODB.Recordset");
-
-
dsStudent.open(strSQL, conn, adOpenDynamic, adLockOptimistic);
-
-
alert("Logging In");
-
-
var strHTML ="";
-
strHTML ="<table cellpadding=0 cellspacing=0 border=1 width='100%' align=center>";
-
strHTML +="<tr><td align=center colspan=4><b>Student Records</b></td></tr>";
-
-
if(!dsStudent.bof)
-
{
-
dsStudent.MoveFirst();
-
while(!dsStudent.eof)
-
{
-
strHTML += "<tr>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(0) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(1) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(2) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(3) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(4) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(5) +"</font></td>";
-
strHTML += "<td><Font face='tahoma'>" + dsStudent.fields(6) +"</font></td>";
-
strHTML += "</tr>";
-
dsStudent.MoveNext();
-
}//close while
-
}// close if statement
-
else
-
{
-
strHTML += "<tr colspan=4><td align=center><font color=red>No Records :(</font></td></tr>";
-
}//close else
-
strHTML = "</table>";
-
document.write(strHTML);
-
}// close Login
3 4141 acoder 16,027
Recognized Expert Moderator MVP
Keep your login button disabled: - <input type="button" ... disabled="disabled">
Then you need some event to trigger the change. One event is the onchange event on the username and password text boxes, e.g. - <input type="text" name="username" ... onchange="enableButton()">
where the function would enable the button if both the text boxes had values in them. To enable a button, set the disabled property to false: - <html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>Login form </title>
-
<script type="text/javascript">
-
function display_submit()
-
{
-
if((document.getElementById("uname").value != "") && (document.getElementById("pwd").value != ""))
-
{
-
document.getElementById("submit_button").disabled = false;
-
}
-
else
-
{
-
document.getElementById("submit_button").disabled = true;
-
}
-
}
-
</script>
-
</head>
-
<body>
-
<form name="form1">
-
<table width="300" cellspacing="10">
-
<tr>
-
<th>Username</th>
-
<td>
-
<input type="text" name="uname" value="" id="uname" onblur="display_submit()"/>
-
</td>
-
</tr>
-
<tr>
-
<th>Password</th>
-
<td>
-
<input type="password" name="password" value="" id="pwd" onblur="display_submit()"/>
-
</td>
-
</tr>
-
<tr>
-
<td colspan="2" align="center">
-
<input type="submit" name="submit_button" id="submit_button" value="LOG IN" disabled="disabled"/>
-
</td>
-
</tr>
-
</table>
-
</form>
-
</body>
-
</html>
acoder 16,027
Recognized Expert Moderator MVP
onchange (triggered on a change) makes more sense that onblur.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John Wolrehammer |
last post by:
After the user login in i want to close the login form. I
can close it but it also closes the whole application.
Can anyone help.
|
by: JPSutor |
last post by:
I have a login form, that if successfully answered, launches another
form. The problem is that the login form remains even after I show the
main form. How do I get rid of the login form?
|
by: David Krussow |
last post by:
Just wondering if/how it would be possible to display a variable string on
the login form - where the string varies depending on the form the user
attempted to access.
To clarify, an unauthenticated user is browsing the site, and tries to open
the UltraSecretContent.aspx page. Forms authentication automatically
redirects the user to login.aspx. I would like for login.aspx to display a
message that reads, "You must log in before viewing...
|
by: Agnes |
last post by:
My login form will call a main form with menu
in my button_OK click event
>dim frmMain as new mainform
>frmMain.show()
>Me.dispose()
The login form didn't close by itself, Please help.. Thanks
|
by: Bob |
last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After
succesfull validayion of user I want to open a first form and close the
loging form that was used, If I write
If IsValidatedUser(UsernameTextBox.Text, PasswordTextBox.Text) Then
frmCompanySelect.Show()
End If
| |
by: Ronald S. Cook |
last post by:
It's been longer that I remember since writing windows (not web) apps.
1) I want to load a main form
2) User clicks login button which brings up login form (on top of main form)
3) Upon entering successful password and clicking ok, login form should go
away
4) Main form should then display admin controls
|
by: jt |
last post by:
The program i have has login form.
After a user has loged in, formX is loaded and i want to dispose all the
forms that where used before (login form).
so the result should be the same as when you use formX as your startup object.
I dont want:
- to hide or minimaze the login form.
- use showdialog.
|
by: knot2afrayed |
last post by:
I am trying to fix error- object does not exist- I want it possible to
allow object not to exist.
I am writing a script on a page that may or may not include a login
form. For example-after a visitor logs in, the login form is no longer
on the page, but other content is still there.
I want to bring focus to the login form using the onLoad in the body
tag.....but if the login form does not exist, I do not want to perform
this function.
|
by: Rinoa |
last post by:
I'm developing a program with a login form. I want the login in form to be the first form that loads, and I want it to close itself when the main CP loads. However, when I set frmLogIn as the startup form and attempt to close it upon loading the next form it closes the entire program.
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
frmMain.Show()
End Sub
That is...
|
by: naharol |
last post by:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |