inserting user email address only if it doesn't alreadyexist...

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default inserting user email address only if it doesn't alreadyexist...

    Hi everyone, I'm fairly new to CF and everything in the new release looks just
    so good that I decided it had to be CF over learning any other scripting
    language....anyway.....

    I'm tasked with creating a large online community site, and obviously the
    first place to start is to create a registration system. Obviously i want to
    use an online form to do this (cfform), with validation on it which then writes
    this information into the database. I have already achieved writing information
    to the database using cfquery and SQL. But have become stuck, when trying to
    validate the fact that two people can not have the same email address. (i have
    designated the email as being the primary key and therefore login along with a
    password). I am using an Access database. Once I have achieved this validation
    I shall be inserting a PayPal system into the registration system as it is
    going to be a paid membership site (paypal looks fairly easy to get working).

    I have tried using SQL (of which I have a basic - intermediate level from uni)
    to do it, something like the below:

    INSERT INTO dRegDetails (dEmail)
    WHERE #FORM.dEmail# <> (SELECT * FROM dRegDetails (dEmail))
    VALUES (
    '#FORM.dEmail#'
    )

    and also I would like an error to pop up if the email address already exists,
    so have enclosed the whole statement in CFIF with a CFELSE. the closest attempt
    i came looks something like below, i have searched high and wide for support
    and came across several different errors whilst changing small things but
    cannot get it to work!! any assistance would be greatly accepted :)

    <cfquery datasource="cfukdoorstaff" name="dRegEmail">
    <cfif isDefined("Form.dEmail")>
    INSERT INTO dRegDetails (dEmail)
    WHERE #FORM.dEmail# <> (SELECT * FROM dRegDetails
    (dEmail))
    VALUES (
    '#FORM.dEmail#'
    )
    <cfelse>
    <cfoutput>
    <b>This email address is already in use by another member, please amend and
    try again.</b>
    </cfoutput>
    </cfif>
    </cfquery>

    P_Roberts Guest

  2. Similar Questions and Discussions

    1. Email address in a form
      I have a form where people enter their e-mail address into a required field. What i am trying to do is when the user clicks submit and it sends the...
    2. email address??
      I have the following code for email <strong><font color="#000000"><a href="mailto:mail@leaktechinc.com"></a></font></strong> How do add...
    3. ASP.NET C# Need to email record after inserting into SQL
      Using DMX 2004, WinXP Pro, MS SQL Server 2000, ASP.NET C#. I am using a standard Insert Record behavior and after the record is successfully...
    4. email - reply address
      After configuring internet access and email accounts using pop3 connector, everything worked fine except for the reply address on the emails. My...
    5. Getting email address.
      When my Users enter their information into my trouble call database, is there a way to get their email address automatically rather than them...
  3. #2

    Default Re: inserting user email address only if it doesn'talready exist...

    Convert you code to a stored proc and use this code

    if not exists (select * from dRegDetails where dEmail =@Email)
    begin
    INSERT INTO dRegDetails (dEmail)
    VALUES (@Email)
    end
    SQLMenace Guest

  4. #3

    Default Re: inserting user email address only if it doesn'talready exist...

    or start with a check
    <cfquery name="check">
    select email from whereever
    where email = '#form.email#"
    </cfquery>
    <cfif check.recordcount is 0>
    insert
    <cfelse>
    do something else

    Dan Bracuk Guest

  5. #4

    Default Re: inserting user email address only if it doesn'talready exist...

    Recently someone had posted a same kind of question.I think youcan use the
    followng query:

    INSERT INTO dRegDetails(Email)
    VALUES (#FORM.dEmail#)
    WHERE #FORM.dEmail# NOT IN (SELECT Email FROM dRegDetails)

    To show a pop up box to show that the email already exits, First read the
    number of records in the table.After you have inserted the new record, Count
    the number of records before insertion and after insertion.If the number of
    records are same then you can use a java script code else if the number of
    records after insertion is higher then you can skip the pop up stuff


    surenr Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139