Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Login Authentication Process


  • Please log in to reply

#1
Melwin

Melwin

    New Member

  • Member
  • Pip
  • 7 posts
I have to create a Login form that asks the user for username and password. If either is invalid it shouldn't allow access and vica versa. I have the following code so far but it doesn't seem to be working the right way nor can i get all the properties to work the right way. I need the ability to add a user, update their password and delete a user using the javascript file and array file. Also the password has to be between 8 and 20 characters.

Login Page Code
:

<html>
<head>
<title>JScript Login <img src='http://www.geekstogo.com/forum/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=';)' /></title>
<script type="text/javascript" src="StudentsArray.js"></script>
<script type ="text/javascript">
function Clear()
{
	usr.value="";
	pswd.value='';
	//document.getElementById("usr").value='';
	//document.getElementById("pswd").value='';
	//alert("testtt");
}

function Login()
{
	//alert("testing login function");
if (document.getElementById("usr").value.length > 1)
{
	if(document.getElementById("pswd").value.length > 8 )
	{
	
	alert("Passed!!! do something " + document.getElementById("usr").value);
	}
}
else
{
	alert("Failed!!! <img src='http://www.geekstogo.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':D' /> do something");
}

}// close Login function
</script>
</head>
<body>

username: <input type="text" name="usr" /><br/>
password: <input type="password" name="pswd" /><br />
<input type="button" id="clear" onclick="Clear()" value="Clear" />
<input type="button" id="login" onclick="Login()" value="Login" />
<input type="button" id="addstudent" value="Add Student" onclick="addstudent()" />

</body>
</html>

Array Page[StudentsArray.js]:

var x;
var students = new Array();

students[0] = "juan";
students[1] = "mike";
students[2] = "tony";

function Display()
{

	alert ("completed populating array (^-^) ");
	for(x=0; x<students.length; x++)
	{

	alert("Student name: " + students[x] );
	}

}// close for loop


function Display2()
{

	alert("completed populating array (^-^)");
	x=0;
while(x<students.length)
{
	
	alert("Student name: " + students[x]);
	x++;
}

}// close for loop

function addstudent()
{
 alert("add person to");
 students.push( document.getElementById("usr").value);
 alert("Name add is: " + document.getElementById("usr").value);

}

  • 0

Advertisements


#2
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
Might look at these and see if you can use them directly or get an idea how to precede with your own as JavaScript is not very secure:

Login Codes:

Website Access Manager - http://www.coffeecup...access-manager/

Depending on what you run:

How to: Create an ASP.NET Login Page - http://msdn.microsof...y/ms178331.aspx
Creating Login Page - http://www.adesdesig...ecure_login.php
Create login page - http://www.interakto...createlogin.htm
PHP Login System with Admin Features: http://www.evolt.org/node/60384

$_SESSION based login system ::Class::: http://bb.dzsoundnir...ic.php?f=3&t=36
Or,: http://answers.yahoo...13175316AASAuQc

PHP Login Script with Remember Me Feature: http://www.evolt.org/node/60265
How to Create a PHP AutoLogin ('Remember Me') Feature using Cookies: http://www.bitreposi...-autologin.html

Edited by AstraNut, 07 November 2010 - 10:51 PM.

  • 0

#3
Melwin

Melwin

    New Member

  • Topic Starter
  • Member
  • Pip
  • 7 posts
I updated my code with the following but i need to add the ability of changing the password, which i partially did but it doesn't work and the password requirment between 8-20 chracters and the ability to remove a user.
var x;
var students = new Array (2) ;
students [0] = new Array (3);

students [0] [0] = "Bob"
students [0] [1] = "Smith"
students [0] [2] = "CST"

students [1] = new Array (3);
students [1] [0] = "Dob"
students [1] [1] = "Blob"
students [1] [2] = "Cob"

students [2] = new Array (3);
students [2] [1] = "Gob"
students [2] [2] = "Doo"
students [2] [3] = "Aob"

students [3] = new Array (3);
students [3] [1] = "bell"
students [3] [2] = "Dell"
students [3] [3] = "cell"

function Display()
{

	alert ("completed populating array (^-^) ");
	for(x=0; x<students.length; x++)
	{

	alert("Student name: " + students[x] );
	}

}// close for loop


function addstudent()
{
 alert("add person to");
 students.push( document.getElementById("usr").value);
 alert("Name add is: " + document.getElementById("usr").value);

}

function deleteu()
{
 alert("Remove person to");
 students.pop( document.getElementById("usr").value);
 alert("Name remove is: " + document.getElementById("usr").value);

}


function Clear()
{
	usr.value="";
	pswd.value='';
	//document.getElementById("usr").value='';
	//document.getElementById("pswd").value='';
	//alert("testtt");
}

function Login()
{
	alert("testing login function");
if (document.getElementById("usr").value.length > 1)
{
	alert("Passed!!! do something " + document.getElementById("usr").value);
}
else
{
	alert("Failed!!! <img src='http://www.geekstogo.com/forum/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':D' /> do something");
}

}// close Login function

function chgpass()
	 {
	 	alert("Change cls");
	 	student [0][2] = "CST"
	 	student [1][2] = document.getElementById("pswd");
	 	}

<html>
<head>
<title>JScript example <img src='http://www.geekstogo.com/forum/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=';)' /></title>
<script type="text/javascript" src="JsArray.js"></script>
</head>
<body>

First Name: <input type="text" name="fname" /><br/>
Last Name: <input type="text" name="lname" /><br/>
User Name: <input type="text" name="usr" /><br/>
Password: <input type="password" name="pswd" /><br />
<input type="button" id="clear" onClick="Clear()" value="Clear" />
<input type="button" id="login" onClick="Login()" value="login" />
<input type="button" id="Display" value="Click To Display" onClick="Display()" />
<input type="button" id="addstudent" value="Add Student" onClick="addstudent()" />
<input type="button" id="addstudent" value="Change Password" onClick="chgpass()" />
<input type="button" id="addstudent" value="Delete User" onClick="deleteu()" />


</body>
</html>

  • 0






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