DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Password protect code (http://www.daniweb.com/forums/thread83396.html)

jeremiah sky Jul 12th, 2007 5:17 pm
Password protect code
 
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?

stymiee Jul 12th, 2007 11:45 pm
Re: Password protect code
 
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.

sillyboy Jul 13th, 2007 12:33 am
Re: Password protect code
 
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.

stymiee Jul 13th, 2007 10:34 am
Re: Password protect code
 
Encryption or not you can still unencrypt it or turn javascript off to defeat it. JavaScript password protection is always a bad idea.

sillyboy Jul 14th, 2007 7:04 am
Re: Password protect code
 
I am not disputing that fact. ;)

jishu Aug 20th, 2007 8:08 am
Re: Password protect code
 
you have any idea where i learn PHP first time?
I have only HTML idea

stymiee Aug 20th, 2007 11:27 am
Re: Password protect code
 
Start with http://www.php.net


All times are GMT -4. The time now is 2:58 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC