Subscribe Now
Receive alert message from us when new articles submitted to our site for free.
Sponsors
Internet MarketingBusiness Letter
Nursing job opportunities
Categories
Home / Computer Programming / Javascript
Print |
Send To Friends |
Add To Favorites |
Comment
Javascript Password ProtectionBy: Timur Abdrakhmanov - http://timurkz.buildtolearn.netArticle Word Count: 542 words [Comments (0)] Total Views: 115 Views |
|
The protection of web pages using a password |
When you click "Login", a yellow box appears where you can enter
the username and password. If the password and login are
correct, then after clicking Enter you will be redirected to
page members.php . All of this is stored in an external file
config.js . The content of config.js in my case is:
The username and password can be either dude1/pass1 or
dude2/pass2 .If you want to add more accounts, just copy and
modify the if statement. In each case, you will be redirected to
page members.php, and you can also change it easily in the code.
This was all i was going to cover. However, i have one more
extremely important notice: Don't use it to protect important
information! All of the above can be bypassed VERY easily by
almost everyone, and you should use it if you don't need any
super-secure protection. KZ Server
Grab this articles
As you see, here our variable is substituted with the word
"the_real_password", which is the actual password.
The second option in protecting a page with Javascript is much
prettier, and it actually allows you to have several login and
password accounts. The code is:
When you click "Login", a yellow box appears where you can enter
the username and password. If the password and login are
correct, then after clicking Enter you will be redirected to
page members.php . All of this is stored in an external file
config.js . The content of config.js in my case is:
{ if (f.username.value == 'dude1' && f.p.value == 'pass1') {
alert('Acess granted') window.location.href='members.php' } if
(f.username.value == 'dude2' && f.p.value == 'pass2') {
alert('Acess granted') window.location.href='members.php' } else
if (f.username.value == '' && f.p.value == '') { alert ('Type
login-password!') } else alert ('Acess
denied'),log.style.visibility='hidden' }
The username and password can be either dude1/pass1 or
dude2/pass2 .If you want to add more accounts, just copy and
modify the if statement. In each case, you will be redirected to
page members.php, and you can also change it easily in the code.
This was all i was going to cover. However, i have one more
extremely important notice: Don't use it to protect important
information! All of the above can be bypassed VERY easily by
almost everyone, and you should use it if you don't need any
super-secure protection. KZ Server
More free articles from http://www.articlesroom.com
