Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-mail Password for Password Protected site 1

Status
Not open for further replies.

peter11

Instructor
Joined
Mar 16, 2001
Messages
334
Location
US
I have just set up a password protected site. I want to have the program email the user their password if they forget it.
 
Well, here's what I've got. Make of it what you will. You would, of course, substitute your own login form.
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<HTML>
<HEAD>
	<TITLE>Forgot Password</TITLE>
</HEAD>

<!--- Define variables --->
<CFPARAM NAME=&quot;Posted&quot; DEFAULT=&quot;No&quot;>
<!--- Insert this code on any page sending email --->
<CFSET tzStruct = GetTimeZoneInfo()>
                <CFSET DateString =
                  &quot;#DateFormat(Now(),'DDD, DD MMM YYYY')#&quot;
                  & &quot; #TimeFormat(Now(),'HH:mm:ss')#&quot;
                  & &quot; -&quot;
                  & &quot;#NumberFormat(tzStruct.utcHourOffset,'00')#&quot;
                  & &quot;00&quot;>

<!--- Get a list of employees from the database. --->
<CFQUERY NAME=&quot;GetEmployees&quot; DATASOURCE=&quot;#application.datasource#&quot;>
		SELECT		PersonID,
					PersonFirstName,
					PersonLastName
		FROM 		PersonTable
		WHERE       PersonActive = Yes
		ORDER BY	PersonLastName
</CFQUERY>

<!--- Has the form been submitted? --->
<CFIF ISDEFINED(&quot;Form.Person&quot;)>
	<CFSET POSTED = &quot;Yes&quot;>
</CFIF>
	
<BODY>

<CFOUTPUT>
<TABLE>
<TR>
    <TD><CFINCLUDE TEMPLATE=&quot;MenuTable.cfm&quot;></TD>
	</CFOUTPUT>
    <TD CLASS=&quot;MainPage&quot;>	
	<!--- Insert main page info here. --->
	<!--- If the form has been submited, insert the data and send success message. --->
		<CFIF #POSTED# EQ &quot;Yes&quot;>
			<CFQUERY NAME=&quot;GetPassword&quot;
					DATASOURCE=&quot;#Application.Datasource#&quot;
					DBTYPE=&quot;ODBC&quot;>
					SELECT *
					FROM PersonTable
					WHERE PersonID = '#Form.Person#'
			</CFQUERY>
			<!--- Send email --->
			<CFMAIL TO=&quot;#GetPassword.PersonFirstName# #GetPassword.PersonLastName# <#GetPassword.PersonEmail#>&quot;
		        	FROM=&quot;Buzz&quot;
		        	SUBJECT=&quot;Your password&quot;
					TYPE=&quot;HTML&quot;>
					<CFMAILPARAM NAME=&quot;Date&quot; VALUE=&quot;#DateString#&quot;>
					Your password is #GetPassword.PersonPassword#.<BR><BR>
					You may login <A HREF=&quot;#Application.RootPath#Directory/EditUser.cfm&quot;>here</A> and change your password.
			</CFMAIL>
			<CFOUTPUT>
				<H2>Thank you, #GetPassword.PersonFirstName#!</H2>
				<H3>You will be receiving an email containing your password shortly.</H3>
			</CFOUTPUT>
		<!--- If the form has not been submitted, present the form. --->
		<CFELSE>
			<DIV ALIGN=&quot;center&quot;>
			<BR><BR>
			<CFOUTPUT>
			<FORM ACTION=&quot;#cgi.script_name#&quot; METHOD=&quot;POST&quot; ENCTYPE=&quot;multipart/form-data&quot;></CFOUTPUT>
				<B>Please select your name from the list.</B><BR>	 	
				<SELECT NAME=&quot;Person&quot;>
				<!--- Display every employee. --->
					<CFOUTPUT QUERY=&quot;GetEmployees&quot;>
						<OPTION VALUE=&quot;#PersonID#&quot;>#PersonFirstName# #PersonLastName#</OPTION>
					</CFOUTPUT>
					</SELECT>
					<BR><BR>
				<CFOUTPUT><INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Send Password&quot;>
			</FORM>
			</CFOUTPUT>
			</DIV>
		</CFIF>
	</TD>
</TR>
</TABLE>

</BODY>
</HTML>
Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top