Search Articles:

 

Home Page

Top Articles

Advertising
Advice
Affiliate Programs
Awards
Business
CGI
Computers
Copywriting
CSS
DHTML
Direct Mail
Domain Names
EBooks
ECommerce
Education
Email
Environment
Family
Finance
Free
Government
Health
Hobbies
Home Business
Home Repair
HTML
Humor
Internet
Javascript
Law



Netcraze Network
Funny Links
Recados Para Orkut
Funny Videos
Street Racing Videos
Crash Videos
Cooking Videos
Sexy Videos
Animal Videos
Surfing Videos
Music News
Funny TV Clips
Fight Videos
Anime Videos
Baseball Videos
Basketball Videos
Football Videos
Golf Videos
Very Funny Pictures
Arcade Games
Myspace Codes
Hockey Videos
Wrestling Videos
Gamer News
Hot Celebs
Fishing Videos
Toys and Gadgets
Movie Trailers
Video Game Trailers
Fitness Videos
Cat Videos
Funny Commercials
Dog Videos
Cheerleading Videos
Poker
Offroad Videos
Hot Links

 Free Facebook Games 
Click Here to add to your profile

 

none

Javascript Password Protection


Published by Timur Abdrakhmanov - http://timurkz.buildtolearn.net
Submitted: 19 April,2005


The protection of web pages using a password comes up earlier or later while developing your site. The most secure way is to implement PHP, ASP or other advanced web programming languages. In this tutorial you will find out how to protect pages using Javascript, because you may need to have a very simple protection, or your current hosting may not support PHP.

The first example we are going to discuss is the prompt() function. The function calls a small box to appear, and unless you enter correct password, you will not be able to view the page. The advantage is that you can't view the source code to find out the password without turning Javascript off. The code is as follows:





Now let's look at the code. When you enter the correct password, a box appears saying that Access is Granted, and the rest of the page is loaded. If the password is incorrect, you are redirected to denied.php. I used a little trick with the password here that can stop some unexperienced hackers ;)) the FAKEPASS is not the actual password, even though you can make it look like it. This is just a variable that is described in an external file - "prompt.gif". This is another trick - the external Javascript file has an extension .gif , which is used for images. The file however contains text, and the server will correctly treat it like a text file, not an image. So the content of prompt.gif is:




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:



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

About the Author

Webmaster of
http://mytunes.com.ru
http://tima.com.ru
http://cs.timurkz.buildtolearn.net

Copyright © 2002-2006 - FreeArticleSearch.com -

ROR