• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

submit form if

New Here ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

Hi i have a username input form, which contains fields "firstname" "surname" "emailaddress"

i have a table called users with the same fields, my input works fine but i need to do a check on the table first to see if the name already exsits this is what i want

if Form.Surname = Users.Surname and Form.FirstName = Users.FirstName and User.EmailAddress = Null
then enter Form.EmailAddress where they match

if Form.Surname = Users.Surname and Form.FirstName = Users.FirstName and User.EmailAddress = is Not Null
then send alert box saying "already a user"

if none of the above enter new record

Could someone please start me off on the code
TOPICS
Advanced techniques

Views

221

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

Something like:
<cfif NOT IsDefined ('email')>
<cfset email = "">
<cfelse>
<cfset email= #URL.email#>
</cfif>
<cfif IsDefined('Submit')>
<cfquery name="email_search" datasource="#Request.MainDSN#">
SELECT email FROM database WHERE email='#FORM.email#'
</cfquery>
<cfif email_search.RecordCount GTE 1>
<cflocation url="index.cfm?reqemail=#FORM.email#&email=taken"
addtoken="no">
</cfif>
<cfif>

Then in your body have:
<cfif email NEQ "">Sorry, that email address already exists, please try
again!</cfif>

Thats how I did it with my newsletter signup to negate duplicates


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

insert into your_table
(surname, firstname, emailaddress)
select distinct '#form.surname#', '#form.firstname#', '#form.emailaddress#'
from some_small_table
where not exists
(select surname
from yourtable
where surname = '#form.surname#'
and firstname = '#form.firstname#' )

By the way, how are you going to cope with two people having the same name?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

Does it matter if they have the same name and not the same email address?
Names are not unique in the world.

Why would this be a requirement?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 13, 2006 Jul 13, 2006

Copy link to clipboard

Copied

LATEST
Many thanks good point

ok there will always be a email address now so what would the code be for

if Form.Surname = Users.Surname and Form.FirstName = Users.FirstName and Form.EmailAddress = User.EmailAddress
then send alert box saying "already a user"

if none of the above enter new record

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation