Password protect code

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2007
Posts: 1
Reputation: jeremiah sky is an unknown quantity at this point 
Solved Threads: 0
jeremiah sky jeremiah sky is offline Offline
Newbie Poster

Password protect code

 
0
  #1
Jul 12th, 2007
I got this script from JavaScript Kit.com. The script refers to entering a userid and password to access one page. I have multiple acquaintances with each getting their own userid and password (it doesn't matter that it isn't encrypted). I am making one page that has the script on it. I would like to modify the code to receive various userid/password combinations to access respective pages.

The original code:

<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="JavaScript") {
if (form.pass.value=="Kit") {
location="page2.html"
}

I wonder if all I need to do is add a couple lines:
<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="JavaScript") {
if (form.pass.value=="Kit") {
location="page2.html"
} if(form.id.value=="example1") {
if (form.pass.value=="pass1") {
location="page3.html"
} if(form.id.value=="example2") {
if (form.pass.value=="pass2") {
location="page4.html"
}


Am I going in the right direction?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Password protect code

 
1
  #2
Jul 12th, 2007
Never ever use javascript top password protect pages. Getting around it is as easy as turning javascript off or just viewing the source code. Use server side password protect like Basic Authentication through .htaccess or a server side programming language like PHP.
Last edited by stymiee; Jul 12th, 2007 at 11:45 pm.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 685
Reputation: sillyboy is on a distinguished road 
Solved Threads: 60
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: Password protect code

 
0
  #3
Jul 13th, 2007
They said encryption was not an issue. So just to answer the question, yes, you are going in the right direction. Just check on those braces if it is not working correctly.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Password protect code

 
0
  #4
Jul 13th, 2007
Encryption or not you can still unencrypt it or turn javascript off to defeat it. JavaScript password protection is always a bad idea.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 685
Reputation: sillyboy is on a distinguished road 
Solved Threads: 60
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: Password protect code

 
0
  #5
Jul 14th, 2007
I am not disputing that fact.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 3
Reputation: jishu is an unknown quantity at this point 
Solved Threads: 0
jishu jishu is offline Offline
Newbie Poster

Re: Password protect code

 
0
  #6
Aug 20th, 2007
you have any idea where i learn PHP first time?
I have only HTML idea
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Password protect code

 
0
  #7
Aug 20th, 2007
Start with http://www.php.net
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC