updating a database with cfid and cftoken

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

  1. #1

    Default updating a database with cfid and cftoken

    Hello,

    I am trying to update a MS Access database using cfid and cftoken. What I'd
    like to do is have the database update where the cfid is the same as the
    '#session.cfid#'. I've tried and few things, but I have been getting error
    messages.

    Code:

    <cfquery datasource="DATASOURCE">
    INSERT INTO TABLENAME(uin,cftoken) VALUES('#session.cfid#','#session.cftoken#')
    </cfquery>

    <cfquery datasource="DATASOURCE">
    UPDATE="TABLENAME"
    SET variable='#form.variable#'
    WHERE uin='#session.cfid#'
    </cfquery>

    I'd also like to be able to identify alert a user that they have already
    completed the survey, so there are no duplicate entries.

    Thanks for your help,

    bw


    wwolff Guest

  2. Similar Questions and Discussions

    1. duplicate cfid cftoken
      hi guys I use cfid and cftoken to identified user profile, recently ,different user may get the same cfid and token when i check web logs,...
    2. cfid, cftoken and jssessionid on this forum
      I was noticing when replys are made and other times these forums pass the CFID, CFTOKEN and a JSSESSIONID. What is the purpose of this strategy, to...
    3. CFTOKEN and CFID
      Hi all: My english is not pretty good but i will try to explain myself. I have an IIS web server and CFMX Server installed on it. In IIS i have a...
    4. Getting rid of cfid and cftoken cookies...
      I am trying to make session on my page, but avoid the use of cfid and cftoken cookies. I am using the attribute setclientcookies="no" in my...
    5. Info for the CFID and CFTOKEN
      Hi i am getting confusion with CFID AND CFTOKEN. whats the difference b/w these two. and how it will helps us in writing the cfm files. as i...
  3. #2

    Default Re: updating a database with cfid and cftoken

    Hi

    i think you have forgotten to post the errors. its better to post your error
    of what you are getting.

    to check whether the user has already completed the survey then write a
    query like the below:
    select * from table where uin="#session.cfid#"

    IF the record if found then just display the survey button to not allow the
    user to do it again.


    vkunirs Guest

  4. #3

    Default Re: updating a database with cfid and cftoken

    If you're using the following:

    UPDATE="TABLENAME"
    SET variable='#form.variable#'
    WHERE uin='#session.cfid#'

    the syntax is wrong.It should be something like:
    UPDATE TABLENAME
    SET Somefield ='#form.variable#'
    WHERE uin='#session.cfid#'



    OldCFer Guest

  5. #4

    Default Re: updating a database with cfid and cftoken

    OldCFer,

    Thanks for pointing out my syntax error, which has done the trick.

    I'm now trying to set up the correct CFIF statement so that a person cannot
    complete the survey twice, but for some reason my code is not working, and a
    usr can enter a survey multiple times. My code:

    <cfquery datasource="swc-survey-database" >
    SELECT uin FROM swctbl1 WHERE uin='#session.cfid#'
    </cfquery>

    <cfif #session.cfid# is 'uin'>

    <p>You have already completed the survey. Thank you for your
    participation.</p>

    <cfelse>

    <cfquery datasource="swc-survey-database">
    INSERT INTO swctbl1(uin,cftoken) VALUES('#session.cfid#','#session.cftoken#')
    </cfquery>

    <cfquery datasource="swc-survey-database">
    UPDATE swctbl1
    SET major='#form.major#'
    WHERE uin='#session.cfid#'
    </cfquery>

    </cfif>

    <cflocation url="swc-thanks.html">

    From this newCFer,

    Thanks!


    wwolff Guest

  6. #5

    Default Re: updating a database with cfid and cftoken

    You have to name your cfqueries when you do selects.
    Then your code would be:

    <cfquery name="GetUIN" datasource="swc-survey-database" >
    SELECT uin FROM swctbl1 WHERE uin='#session.cfid#'
    </cfquery>

    <cfif GetUIN.RecordCount>
    <p>You have already completed the survey. Thank you for your participation.</p>
    <cfelse>
    <cfquery datasource="swc-survey-database">
    INSERT INTO swctbl1(uin,cftoken,major)
    VALUES('#session.cfid#','#session.cftoken#','#form .major#')
    </cfquery>
    </cfif>

    There's no reason to insert then update. Just insert it all at once.


    OldCFer Guest

  7. #6

    Default Re: updating a database with cfid and cftoken

    Thanks, Larry.

    That did the trick.

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