Important alert: (current site time 7/16/2013 6:54:10 AM EDT)
 

VB icon

Password Protection

Email
Submitted on: 12/9/2001 10:17:34 PM
By: Demetrious Maltsiniotis  
Level: Beginner
User Rating: By 2 Users
Compatibility: Cold Fusion 4.5
Views: 13144
(About the author)
 
     This simple code allows you to restrict certain parts of, or eniter web pages from users without the correct username/password. The nice thing about this pice of code is that because we use cold fusion, it is EXTREEMLY flexible, and secure.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :Password Protection
//**************************************
This code is not copyrighted and is yours for free to use/alter to your hearts content.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Password Protection
// Description:This simple code allows you to restrict certain parts of, or eniter web pages from users without the correct username/password. The nice thing about this pice of code is that because we use cold fusion, it is EXTREEMLY flexible, and secure.
// By: Demetrious Maltsiniotis
//
// Assumes:The page that has the login form can be named whatever you want. In my example, the form that accualy checks the username and password is called validate.cfm
But ofcourse you can name it whatever you want, just be sure to edit the code apropriately.
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=34&lngWId=9//for details.//**************************************

<!--- This part of the code goes in your login page, the name of the cfm file can be anyuting. Ofcouse you can spice this page up a bit. --->
<html>
<H2> Please Enter your username and Password</H2>
<br>
<cfform action="validation.cfm" method="POST" enablecab="Yes">
Username: <cfinput type="Text" name="Username" required="Yes" maxlength="12">
<br>
Password: <cfinput type="Password" name="Password" required="no" maxlength="12">
<br>
<br>
<input type="submit" value="Login">
</cfform>
</html>
<!--- This part of the code goes into your validation.cfm file --->
<html>
<head>
	<title>Validation Page</title>
</head>
<!--- here we check to see if the username = "guest" --->
<cfif username eq "guest">
<!--- and here we check to se if the subsequent password for "guset" alost queals "guest" --->
<cfif password eq "guest">
<h3>Welcome guest!, you can put anything you want in here: queries, private html, or whatever you deem worthy of being protected.</h3>
<cfelse>
<center><h2>Invalid Password!</h2></center>
</cfif>
<cfelse>
<center><h2>Invalid Username!</h2></center>
</cfif>
<h3>Anything you put here will/can be seen by anyone who clicks the logon button, reguardless of username/password. So by this example you can see how easy it is to restrict only certain things, or entier pages from invalid users. Can INCREASE the flexibility of this code by tieing it in with a username/password database, and by playing around with CFOUTPUT a little you can see the possibilities are nearly limitless as to what you want to do. And that is beauty of Cold Fusion.
<br>
<br>
<h4>If have any questions, or need any help at all, please feel free to email me at <a href="mailto:remote72@aol.com">remote72@aol.com</a></h4>
</html>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

12/9/2001 10:30:51 PMWeb Programmer

I realy like your use of code for this porpos, I tried it out, tied into a user/pass db and got excelent results, great code man.
(If this comment was disrespectful, please report it.)

 
6/24/2003 12:31:55 AMShannon A. Masters

you should use CFLOCK, and store all username / pass values into a session scope.. EG:












to check if user logged in:




Welcome #UserName#!!


Note, there may be 1 or 2 typo's, i didn't copy and paste any code.. just typed it all then.

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.