Hi,
I have a subscribe form, and when somebody new signs up, I would like it to 
send a e-mail. I have a cfmail block here:

   <cfmail from="#FORM.Email#"
                        to="my mail address" 
                        subject="New Sign Up">
  From: #form.name# (#form.email#)  

  New Subscrber:
  #form.name#
  #form.Email#
   </cfmail>

below is the whole form. In the out put file, it writes all the information to 
a database. Would it be better to put the cfmail part in the output file?
Thanks,
Johnny

<!--- Prompt User To Enter information --->
<cfform action="subscribe_output.cfm" method="post">

    <!--- Start Contact Form--->
                
                
                <cffunction name="makeRandomString" returnType="string" 
output="false">
      <cfset var chars = "23456789ABCDEFGHJKMNPQRS">
      <cfset var length = randRange(4,6)>
      <cfset var result = "">
      <cfset var i = "">
      <cfset var char = "">
      
      <cfscript>
      for(i=1; i <= length; i++) {
          char = mid(chars, randRange(1, len(chars)),1);
          result&=char;
      }
      </cfscript>
          
      <cfreturn result>
  </cffunction>
  
  <cfparam name="form.name" default="">
  <cfparam name="form.email" default="">
  <cfparam name="form.comments" default="">
  <cfset showForm = true>
  <style type="text/css">
  .form {
        font-family: Verdana, Geneva, sans-serif;
        font-size: 12px;
}
  </style>
  
  
  <cfif structKeyExists(form, "sendcomments")>
   <cfset error = "">
   <cfif not len(trim(form.name))>
   <cfset error = error & "You must include your name<br>">
   </cfif>
      <cfif not len(trim(form.email)) or not isValid("email", form.email)>
   <cfset error = error & "Include a valid email address<br>">
   </cfif>
   <cfif not len(trim(form.comments))>
   <cfset error = error & "Please enter a Comment<br>">
   </cfif>
   <cfif hash(form.captcha) neq form.captchaHash>
   <cfset error = error & "You did not enter the right text<br />">
   </cfif>
  
   <cfif error is "">

   
   <cfmail from="#FORM.Email#"
                        to="my mail address" 
                        subject="New Sign Up">
  From: #form.name# (#form.email#)  

  New Subscrber:
  #form.name#
  #form.Email#
   </cfmail>
   <cfset showForm = false>
   </cfif>
  </cfif>
   
  <cfif showForm>
   <cfif structKeyExists(variables, "error")>
   <cfoutput>
   <p><p>
        Please correct these errors:<br>
   <span class="error" style="color: ##990000;">#error#</span>
   
   </p>
   </cfoutput>
   </cfif>
   
   <cfoutput>
   <form action="subscribe_output.cfm" method="post">
   <table width="609" height="329">
   <tr>
   <td width="184" align="right" class="form">Your Name&nbsp;</td>
   <td width="413"><input name="name" type="text" class="form" 
value="#form.name#"></td>
   </tr>
   <tr>
   
   </tr>
   <tr>
   <td align="right" class="form">Your Email &nbsp;</td>
   <td><input name="email_address" type="text" class="form" 
value="#form.email#"></td>
   </tr>
   <!--- test e-mail check --->
    <tr>
      <td align="right">Validate Email</td>
      <td><cfinput type="text" name="email_address2"  class="form" 
validateat="onSubmit" validate="email" required="yes"></td>
    </tr>
   <tr>

   </tr>
   
 
   
   <tr>
   
   </tr>
       <tr>
            <td class="form">Enter Text (Case Sensative)</td>
            <td><input name="captcha" type="text" class="form"></td>
       </tr>
  
       <cfset captcha = makeRandomString()>
       <cfset captchaHash = hash(captcha)>
       <input type="hidden" name="captchaHash" value="#captchaHash#">
       
       <tr>
       <td></td>
            <td colspan="2"><cfimage action="captcha" 
                                                                         
width="100" 
                                             height="30" 
                                             text="#captcha#" 
                                             fonts="verdana,arial"
                                             fontsize="12"></td>
       </tr>
       <tr>
                <td></td>
                <td><a href="JavaScript:location.reload(true);" 
class="form">Refresh this image</a></td>
</tr>
<tr>
                
</tr>
       
   <tr>
   <td> </td>
   <td><input type="submit" name="sendcomments" value="Subscribe"></td>
   </tr>
   </table>
   </form>
   </cfoutput>
  <cfelse>
   <cfoutput>
   <p>
   Thank you for sending your comments, #form.name#.
   </p>
   </cfoutput>
  </cfif>
  
  
  
  <!--- End Contact Form---> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5766
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to