School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 309,261 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,471 people online right now. Registration is fast and FREE... Join Now!




Verify Email address (or any feild) matches and not already in DB

 

Verify Email address (or any feild) matches and not already in DB

cumupkid

24 Apr, 2009 - 04:26 AM
Post #1

D.I.C Head
**

Joined: 22 Jan, 2008
Posts: 61

I am posting this so that others can use it and/or tell me a better way.

This is the code I used to first verify that the two email address fields match and second that the emaill address does not exist in a BD. This is all done in one form.


CODE

<cfif isdefined("form.firstname")>

    <cfif form.email eq form.emailverify>
            
        <cfquery name="ckDup" datasource="#application.datasource#">
              SELECT *
            FROM customers
            WHERE EMAIL = '#form.email#'
        </cfquery>
        
               <cfif ckDup.recordcount EQ 0>
                <cfinvoke
                component="cfcs.customers" method="insertcustomer">
                <cfinvokeargument name="formdata" value="#form#"/>
                </cfinvoke>
                <cflocation url="index.cfm?thankyou" addtoken="no">
            <cfelse>
                <cfset errormessage2 = "That Email Already Exists"><div id="errormessage">That Email Already Exists</div>      
            </cfif>
    
    <cfelse>
        <cfset errormessage1 = "Your email addresses did not match"><div id="errormessage">Your email addresses did not match</div>
    </cfif>

</cfif>    

<cfparam name="form.firstname" default="">
<cfparam name="form.lastname" default="">
<cfparam name="form.email" default="">
<cfparam name="form.primaryphone" default="">
<cfparam name="form.secondaryphone" default="">
<cfparam name="form.address" default="">
<cfparam name="form.city" default="">
<cfparam name="form.state" default="">
<cfparam name="form.postalcode" default="">

<h2>Join our email list</h2>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>


      <tr>
        <td>*First Name:</td>
        <td><cfinput type="text" name="firstname" value="#form.firstname#" required="yes" id="firstname" tabindex="1" maxlength="20"></td>
    </tr>
    <tr>
        <td>*Last Name:</td>
        <td ><cfinput type="text" name="lastname" value="#form.lastname#" required="yes" id="lastname" tabindex="2" maxlength="20"></td>
    </tr>
    <tr>
        <td>*Email:</td>
        <td ><cfinput type="text" name="email" value="#form.email#" validateat="onSubmit" validate="email" required="yes" id="email" tabindex="3" maxlength="50"></td>
    </tr>
    <tr>
        <td>
            <cfif isDefined('errormessage1')><div id="errorMessage">*Verify Email:</div>
            <cfelse>*Verify Email:</cfif>        </td>
        <td ><cfinput type="text" name="emailverify"  required="yes" id="emailverify" tabindex="4" maxlength="50"></td>
    </tr>
    <tr>


User is offlineProfile CardPM
+Quote Post


Posts in this topic

Fast ReplyReply to this topicStart new topic

Time is now: 11/26/09 10:09AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month