#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    New to ColdFusion [Forms]


    Hello,

    I'm new to the forum and I noticed devshed had a coldfusion section,
    I'm new to coldfusion and I want to learn,
    I know <cfif>, <cfquery>, all that funky stuff

    But I have a problem (Sure its easy but like I said I am new...)
    I'm using forms to enter user-input data the form code looks like this

    Code:
    <form method="post" action="submit.cfm" name="submit">
    	<input type="text" name="name" />
    	<input type="text" name="email" />
    	<input type="submit" name="submit" value="Send" />
    </form>
    I basicly want to use <cfquery> to insert/update data but I don't know how to get the input from the form (name, email)

    Any help?

    Thank you in advance!
    If I am not clear just let me know I'll try re-word
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    The form fields posted in the form are available in the FORM scope.

    Since you're new to CF, I really can't overemphasize the need to read the documentation, which explains all of this and more.

    Welcome to CF-Land.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0
    Originally Posted by kiteless
    The form fields posted in the form are available in the FORM scope.

    Since you're new to CF, I really can't overemphasize the need to read the documentation, which explains all of thisand more.

    Welcome to CF-Land.
    Thank you for the link I shall read that!
    And thanks for the welcome.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0
    Sorry for the double post, But I got past the first part now I'm stuck again and didn't want to make a new thread

    This is my code for "spam"

    Code:
    <cfquery name="MarkAsSpam" datasource="#DSN#">
    	UPDATE cms_comments
    	SET comment = '<i>Marked as spam by staff</i>'
    	WHERE id = '#form.id#'
    </cfquery>
    
    <cfquery name="PointMax" datasource="#DSN#">
    	SELECT *
    	FROM users
    	WHERE id = '#form.userid#'
    </cfquery>
    
    <cfif user.user_news_spam is 3>
    	<cfquery name="SetPoint3" datasource="#DSN#">
    		UPDATE users
    		SET user_news_spam = '3'
    		WHERE id = '#form.userid#'
    	</cfquery>
    <cfelse>
    	<cfquery name="AddSpamPoint" datasource="#DSN#">
    		UPDATE users
    		SET user_news_spam = user_news_spam + 1
    		WHERE id = '#form.id#'
    	</cfquery>
    </cfif>
    When I submit and goto "spam.cfm" I get this error...

    Code:
    Element USER_NEWS_SPAM is undefined in USER.
    Any help on this?
    Much appreciated!
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    You reference query columns using the query name. i.e. PointMax.USER_NEWS_SPAM.

    Again, this is all explained completely in the documentation, as well as in any book on CF. The CF Web Application Construction Kit (WACK) is the unofficial bible on CF if you find the official docs too dry.

    You'll find learning this a lot easier (and faster) if you go through the docs or read the book.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0
    You may also want to look up <cfqueryparam> tag while you're at it. Make good habits of using this tag in your query WHERE clauses
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0
    Oh OK,
    I've seen them used but I never seen the point in them,
    Ill have a look into it can you give a brief on what it does?
  14. #8
  15. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968

IMN logo majestic logo threadwatch logo seochat tools logo