Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Login User


  • Please log in to reply

#1
Melwin

Melwin

    New Member

  • Member
  • Pip
  • 7 posts
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. 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
Delete A User
Password Length [9-20 Characters]
Display The current 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.

Anybody 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. Attached File  ExampleDB.zip   15.48KB   62 downloads 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;">

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 />

<input type="radio" name="fnd" value="DisAll" id="fnd1"/> Display all records<br />
<input type="radio" name="fnd" value="Insert" id="fnd2"/> Add new record<br />
<input type="radio" name="fnd" value="update" id="fnd3"/> update record<br />
<input type="radio" name="fnd" value="delete" id="fnd4"/> delete record<br />
<input type="radio" name="fnd" value="Discur" id="fnd5"/> Display current record

<h1>Call method 1</h1>
<input type="button" id="Display" onclick="startUp()" value="submit" />
<h1>Call method 2</h1>
<input type="button" id="Display2" onclick="updateStudent()" value="Method2" />

</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 getSelection(radioObj) {
    //alert("radobj length is: " + radioObj.length);

    var radLength = radioObj.length;
    if (radLength == undefined)
    {
        return "";
    }//if
    else
    {
      for (var i = 0; i < radLength; i++)
      {
        if (radioObj[i].checked)
        {
                return radioObj[i].value;
            }// if
        }//for

    }// else

 }

function startUp() {
    var fn = document.getElementById("studentfn").value;
    var ln = document.getElementById("studentln").value;
    var studid = document.getElementById("studentid").value;
    var radioObj = document.forms['student'].elements['fnd'];
    var chc = getSelection(radioObj);
    alert("fname: " + fn + " lname: " + ln + " studentid: " + studid + " task: " + chc);

    switch (chc) {
        case 'DisAll':
            Display();
            break;
        case 'Insert':
            insertStudent();
            break;
        case 'update':
            updateStudent();
            break;
        case 'delete':
            deleteStudent();
            break;
        case 'Discur':
            alert("coming soon (^-^)");
            break;
        default:
            alter("please a task!");
    }// close switch
    
}
 
 
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 += "</tr>";
            dsStudent.MoveNext();
        }//close while
    }// close if statement
    else
    {
        strHTML += "<tr colspan=4><td align=center><font color=red>No Records <img src='http://www.geekstogo.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':D' /></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 strSQL = "insert into Student(fname, lname,dob) values('" + fn + "','" + ln + "','" + 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("insert completed");
}// close insertStudent

Edited by Melwin, 30 November 2010 - 10:37 PM.

  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP