| | |
Password protect code
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Solved Threads: 0
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?
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?
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
![]() |
Similar Threads
- How to password protect a file folder (Windows NT / 2000 / XP)
- How do I password protect folders? (Windows NT / 2000 / XP)
- password protect folder on a network (Network Security)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to make selected index zero for dropdown list box in java script..?
- Next Thread: How to get the javascript objects in html body tag
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file form forms google gwt gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha microsoft mimic object onerror onmouseoutdivproblem onreadystatechange parent pdf php player post problem progressbar rated rating regex runtime scroll search security select session shopping size software sql star stars synchronous text textarea unicode validation w3c web website window windowofwords windowsxp wysiwyg xml \n






