Javascript newbie

This is a discussion on "Javascript newbie" within the JavaScript Forum section. This forum, and the thread "Javascript newbie are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 3rd, 2007, 01:26
New Member
Join Date: Aug 2007
Location: Toronto
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cool How to change login/password script for multiple users

Help....I am a Javascript newbie! I am trying to create a js file with login IDs and passwords for multiple users. The code I have is for one user.
How do I change this code to accomodate multiple users:
Code: Select all
function authUser(form) { 
if (form.Username.value=="member1") { 
if (form.Password.value=="testing") { 
location="Welcome.html" 
} else { 
location="UnAuthorized.html"
} 
} else { 
location="UnAuthorized.html"
} 
}

I have tried a whole lot of things but nothing recognizes more than one user. Any help would be greatly appreciated.

Last edited by karinne; Aug 3rd, 2007 at 12:02. Reason: Please use [ code ]...[ /code ] tags when displaying code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 3rd, 2007, 06:10
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript newbie

You can either make an array of usernames and passwords but then that's not dynamic. Your other option is to have some kind of database (mySQL, file).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 7th, 2007, 22:41
Reputable Member
Join Date: Dec 2005
Location: U.S.A.
Posts: 155
Thanks: 0
Thanked 4 Times in 4 Posts
Re: Javascript newbie

When i think of JavaScript and passwords I think:

alert("DO NOT USE JAVASCRIPT FOR PASSWORDS!")

Not a good idea. I hope this is for learning purposes. If you use JS anyone can see the passwords and all the other personal information. Not to mention that they can just shut it off and access anything they want.

Use a server side language such as PHP or ASP to check for passwords and usernames against a database.

Although it is ok to use JS to validate the entry before sending off to the server.

You cannot access a MySQL database with JS.

Good Luck,
Scott
__________________
Web Design and Development
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 7th, 2007, 23:06
New Member
Join Date: Aug 2007
Location: Toronto
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript newbie

thanks. the idea was simply to validate passwword and re-type password before the form data goes off to the server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 9th, 2007, 13:42
Up'n'Coming Member
Join Date: Aug 2007
Location: Bicester
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript newbie

Code: Select all
var users = new Array();
users["mary"] = "secret"; //associative array
users["fred"] = "password";
//add new uers here
 
 
function authUser() { 
 
var user = form.Username.value;
var password = form.password.value;
 
 
if (users[user]==password) { 
alert('ok'); 
}
else
{
alert('no entry'); 
}
 
}
 
authUser();

of course like ScottR says this is no security at all.

On a minor point perhaps I can correct Scott? If you wanted to use javascript to access a mySQL database you could use JScript.net (basically Javascript with bells) or - I think Borland used to make a web server Intraserver that used Javascript. Or JScript in ASP. Unusual but possible

Last edited by Kropotkin; Aug 9th, 2007 at 14:46. Reason: Please use [ code ]...[ /code ] tags when displaying code!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 23rd, 2007, 16:54
Junior Member
Join Date: Jan 2007
Location: Michigan
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript newbie

could one not easily hide the data in an external .js file though to keep securaty?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Aug 23rd, 2007, 18:07
Up'n'Coming Member
Join Date: Aug 2007
Location: Bicester
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript newbie

I don't think so Joe

The external js file is visible - unless you are talking signing it and encrypting it - but i don't think anyone does that? Netscape had a system but as far as i know it never caught on?

Justin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
login and passord, javascipt, multiple users

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie to Javascript dapirates JavaScript Forum 5 Mar 11th, 2008 21:21
newbie javascript problem c_martini JavaScript Forum 10 Sep 7th, 2007 08:19
Newbie, Please help with javascript links lea JavaScript Forum 1 Nov 9th, 2006 14:45
Newbie in Javascript ktsirig JavaScript Forum 1 Mar 12th, 2006 05:20
JavaScript Newbie Seeks Guidance jswebdev JavaScript Forum 0 Dec 5th, 2005 20:44


All times are GMT. The time now is 23:55.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42