School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,116 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,289 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 Rate Topic: -----

#1 cumupkid  Icon User is offline

  • D.I.C Head
  • PipPip
  • Group: Members
  • Posts: 61
  • Joined: 22-January 08


Dream Kudos: 0

Post icon  Posted 24 April 2009 - 04:26 AM

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.


<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>


Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



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