34 Replies Latest reply on Dec 12, 2015 7:48 PM by Carl Von Stetten

    Felix Mayowa

    felixm71880667

      Good day everyone please i'm a beginner in coldfusion. i really need your help i've read books about coldfusion but i dont understand them.  is there any book for a beginner like me

        • 1. Re: Felix Mayowa
          BKBK Adobe Community Professional & MVP

          Hi Felix, welcome to the world of ColdFusion. Which books have you been reading?

           

          Search the web for Coldfusion tutorials for beginners. I would recommend Learn CF in a Week. You should return to this forum with any questios you may have.

          1 person found this helpful
          • 2. Re: Felix Mayowa
            felixm71880667 Level 1

            Thank You. but it is not explanatory. I read coldfusion developers guide 9. I cant apply it to a real practical

            • 3. Re: Felix Mayowa
              BKBK Adobe Community Professional & MVP

              The Adobe Developer Guide is perhaps too advanced for the beginner. Have you had a look at the LearnCFInAWeek tutorial? It has plenty of pactical examples.

              • 4. Re: Felix Mayowa
                felixm71880667 Level 1

                yes. i guess I'll go back to it again

                • 5. Re: Felix Mayowa
                  felixm71880667 Level 1

                  please i want to add a date of birth in database but its giving the error "Column count doesn't match value count at row 1"

                  • 6. Re: Felix Mayowa
                    Dave Ferguson Level 3

                    It would be extremely helpful if you posted the code that is causing your issue.

                    • 7. Re: Felix Mayowa
                      felixm71880667 Level 1

                      <!---Beginning of Database--->

                        <cfif isDefined("form.save")>

                        <cfquery name="feltec" datasource="#Request.MainDSN#">

                        INSERT INTO user(

                        username,

                        firstname,

                        lastname,

                        email,

                        address

                        )

                        VALUES(

                        '#Form.username#',

                        '#Form.firstname#',

                        '#Form.lastname#',

                        '#Form.email#',

                        '#Form.address#'

                        )

                        </cfquery>

                        </cfif>

                        <cfif isDefined("form.save")>

                        <cfquery name="feltec" datasource="#Request.MainDSN#">

                        INSERT INTO password(

                        password,

                        retypepassword,

                        phone,

                        dateofbirth

                        )

                        VALUES(

                        '#Form.password#',

                        '#Form.retypepassword#',

                        '#Form.phone#'

                        '#Form.dateofbirth#'

                        )

                        </cfquery>

                        </cfif>

                       

                       

                      <div class="container-fluid">

                        <div class="page-header">

                        <form class="form-horizontal" method="POST">

                        <div class="container">

                        <div class="form-group has-feedback">

                        <input class="form-control" type="text" placeholder="Username" name="username" required>

                        <input class="form-control" type="text" placeholder="Firstname" name="firstname" required>

                        <input class="form-control" type="text" placeholder="Lastname" name="lastname" required>

                        </div>

                        <div class="form-group">

                        <input class="form-control" type="text" id="email" name="email" placeholder="Email Address" required>

                        <input class="form-control" type="password" id="pwd" name="password" placeholder="New Password" required>

                        <input class="form-control" type="password" id="retypepassword" name="retypepassword" placeholder="Re-type Password" required>

                        <input class="form-control" type="tel" id="phone" name="phone" placeholder="Phone Number" required>

                        <input class="form-control" type="text" id="address" name="address" placeholder="Address" required>

                        </div>

                        <div class="form-group" for="birthday">

                        <label role="birthday">Date Of Birth</label>

                        <br>

                        <h6>Date of Birth Combined with your security question, this will help us verify your identity if you forget your password or need to reset it.</h6>

                        <select name="dateofbirth" id="birthday" required>

                        <option>Days</option>

                        <cfloop index="i" from="1" to="31">

                        <cfoutput><option value="#i#">#i#</option></cfoutput>

                        </cfloop>

                        </select>

                        <select name="dateofbirth" id="birthday" required>

                        <option>Month</option>

                        <cfloop index="i" from="1" to="12">

                        <cfoutput>

                        <option value="#i#">#monthAsString(i)#</option>

                        </cfoutput>

                        </cfloop>

                        </select>

                        <select name="dateofbitrh" id="birthday" required>

                        <option>Year</option>

                        <cfloop index="i" from="1901" to="2015">

                        <cfoutput>

                        <option value="#i#">

                        #i#

                        </option>

                        </cfoutput>

                        </cfloop>

                        </select>

                        </div>

                        <label class="control-label">Gender</label>

                        <br>

                        <div class="radio">

                        <label class="radio-inline"><input type="radio" name="optradio" value="male" checked>Male</label>

                        <label class="radio-inline"><input type="radio" name="optradio" value="female">Female</label>

                        </div>

                        <input class="form-control" type="tel" placeholder="Optional Recovery Number" name="optional" required>

                        <br>

                        <label class="control-label">I agree to the <a href="index.cfm">Feltec</a> <a href="##" name="Terms and Condition">Terms</a> and <a href="##" name="Privacy">Privacy</a></label>

                        <br>

                        <button class="btn btn-Success btn-block" type="submit" name="save">Create Account<span class="glyphicon glyphicon-log-in"></span></button>

                        </div>

                        </form>

                        </div>

                      </div>

                      • 8. Re: Felix Mayowa
                        haxtbh Level 4

                        You are missing a comma after '#Form.phone#' in the SQL insert query.

                         

                        The error you are getting basically means you are not providing the correct amount of values to insert relative to the fields you are trying to insert to.

                        1 person found this helpful
                        • 9. Re: Felix Mayowa
                          Carl Von Stetten Adobe Community Professional & MVP

                          felixm71880667, in the future, when you have a new question, please post it separately to the forum.  This allows each question to be responded to in context, and when the question is satisfactorily answered, it can be marked as "Answered".  This helps forum users find answers to their questions more quickly without having to wade through lengthy off-topic content.


                          Thanks,

                          -Carl V. - Moderator

                          • 10. Re: Felix Mayowa
                            Dave Ferguson Level 3

                            Ok... couple of things here.  The 2 tables you have don't relate in any way.  So, am not sure how you would look up a users password with this design.  Secondly, unless you want to be sql injected user query params, for everything. 

                             

                            The error you are getting is being caused by the insert into password table as there is no comma after the phone value.

                             

                            Thanks,


                            --Dave

                            • 11. Re: Felix Mayowa
                              Carl Von Stetten Adobe Community Professional & MVP

                              In addition to what Dave Ferguson and haxtbh said, I think you need to rethink your table structures. You at least need to have one column in each table that match in order to link or join them. Username seems a logical column, unless you've got an auto-generated id column that isn't shown in your queries (so you need username to exist in both tables, and they need to match each other).  Also, why is "phone" and "dateofbirth" in the password table rather than the user table?  Do you even need a separate passsword table?

                               

                              Also, if you are going to store passwords, you should definitely be encrypting them. There are various techniques for this, and various built-in functions and open-source community solutions are available, depending on which version of ColdFusion you are running.

                               

                              -Carl V.

                              • 12. Re: Felix Mayowa
                                BKBK Adobe Community Professional & MVP

                                In case you are unaware of it, the query parameter that Fergusondj talks about is cfqueryparam. Aside from improving security,

                                <cfqueryparam value = "#form.dateofbirth#" cfsqltype = "cf_sql_date"> will convert the string form.dateofbirth to a date that your data source will recognize.

                                • 13. Re: Felix Mayowa
                                  felixm71880667 Level 1

                                  Thanks to everyone. I really appreciate this family.

                                  • 14. Re: Felix Mayowa
                                    Carl Von Stetten Adobe Community Professional & MVP

                                    felixm71880667 I'm going to mark the first answer from BKBK as Correct, since it addressed your original question.  If you run into any additional problems, or need more help on the query issue above, we'll carve the whole query discussion off to a separate topic to keep the discussion thread easier to follow.

                                     

                                    -Carl V. - Moderator

                                    • 15. Re: Felix Mayowa
                                      felixm71880667 Level 1

                                      stii can't cast the date of birth to Date value. please help

                                      • 16. Re: Felix Mayowa
                                        felixm71880667 Level 1

                                        <!---Beginning of Database--->

                                          <cfif isDefined("form.save")>

                                          <cfquery name="feltec" datasource="#Request.MainDSN#">

                                          INSERT INTO user(

                                          username,

                                          firstname,

                                          lastname,

                                          email,

                                          password,

                                          retypepassword,

                                          phone,

                                          address,

                                          dateofbitrh,

                                          sex,

                                          optionphone

                                          )

                                          VALUES(

                                          '#Form.username#',

                                          '#Form.firstname#',

                                          '#Form.lastname#',

                                          '#Form.email#',

                                          '#Form.password#',

                                          '#Form.retypepassword#',

                                          '#Form.phone#',

                                          '#Form.address#',

                                        <cfqueryparam value = "#form.dateofbirth#" cfsqltype = "cf_sql_date">,

                                          '#Form.sex#',

                                          '#Form.optionphone#'

                                          )

                                          </cfquery>

                                          </cfif>

                                        <!---End of database--->

                                        • 17. Re: Felix Mayowa
                                          Carl Von Stetten Adobe Community Professional & MVP

                                          What error are you getting?  Can you provide a sample of a date value coming from the form that isn't working?

                                          • 18. Re: Felix Mayowa
                                            BKBK Adobe Community Professional & MVP

                                            felixm71880667 wrote:

                                             

                                            <!---Beginning of Database--->

                                              <cfif isDefined("form.save")>

                                              <cfquery name="feltec" datasource="#Request.MainDSN#">

                                              INSERT INTO user(

                                              username,

                                              firstname,

                                              lastname,

                                              email,

                                              password,

                                              retypepassword,

                                              phone,

                                              address,

                                            dateofbitrh,

                                              sex,

                                              optionphone

                                              )

                                              VALUES(

                                            '#Form.username#',

                                              '#Form.firstname#',

                                              '#Form.lastname#',

                                              '#Form.email#',

                                              '#Form.password#',

                                              '#Form.retypepassword#',

                                              '#Form.phone#',

                                              '#Form.address#',

                                            <cfqueryparam value = "#form.dateofbirth#" cfsqltype = "cf_sql_date">,

                                            '#Form.sex#',

                                              '#Form.optionphone#'

                                              )

                                              </cfquery>

                                              </cfif>

                                            <!---End of database--->

                                            Two things:

                                            1) there appears to be a typing error: "dateofbitrh";

                                            2) use cfqueryparam for ALL the form values.

                                            • 19. Re: Felix Mayowa
                                              felixm71880667 Level 1

                                              <select name="dateofbirth" id="birthday" required>

                                                <option>Days</option>

                                                <cfloop index="i" from="1" to="31">

                                                <cfoutput><option value="#i#">#i#</option></cfoutput>

                                                </cfloop>

                                                </select>

                                                <select name="dateofbirth" id="birthday" required>

                                                <option>Month</option>

                                                <cfloop index="i" from="1" to="12">

                                                <cfoutput>

                                                <option value="#i#">#monthAsString(i)#</option>

                                                </cfoutput>

                                                </cfloop>

                                                </select>

                                                <select name="dateofbirth" id="birthday" required>

                                                <option>Year</option>

                                                <cfloop index="i" from="1901" to="2015">

                                                <cfoutput>

                                                <option value="#i#">

                                                #i#

                                                </option>

                                                </cfoutput>

                                                </cfloop>

                                                </select>

                                              • 20. Re: Felix Mayowa
                                                felixm71880667 Level 1

                                                not still working

                                                 

                                                <cfif isDefined("form.save")>

                                                  <cfset today = Now()>

                                                  <cfquery name="feltec" datasource="#Request.MainDSN#">

                                                  INSERT INTO user(

                                                  username,

                                                  firstname,

                                                  lastname,

                                                  email,

                                                  password,

                                                  retypepassword,

                                                  phone,

                                                  address,

                                                  dateofbitrh,

                                                  sex,

                                                  optionphone

                                                  )

                                                  VALUES(

                                                  <cfqueryparam value="#Form.username#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.firstname#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.lastname#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.email#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.password#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.retypepassword#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.phone#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value="#Form.address#" cfsqltype="cf_sql_varchar">,

                                                  <cfqueryparam value = '#form.dateofbirth#' cfsqltype = "cf_sql_date">,

                                                  '#Form.sex#',

                                                  <cfqueryparam value="#Form.optionphone#" cfsqltype="cf_sql_varchar">

                                                  )

                                                  </cfquery>

                                                  </cfif>

                                                <!---End of database--->

                                                • 21. Re: Felix Mayowa
                                                  felixm71880667 Level 1

                                                  please help me

                                                  • 22. Re: Felix Mayowa
                                                    haxtbh Level 4

                                                    Help with what? BKBK gave you the solution to your last problem, which appeared to be a typo. You still have not corrected the type. "dateofbitrh" is still incorrect.

                                                    • 23. Re: Felix Mayowa
                                                      felixm71880667 Level 1

                                                      i have corrected it but its still not working. check it out again.

                                                       

                                                      <!---Beginning of Database--->

                                                        <cfif isDefined("form.save")>

                                                        <cfset today = Now()>

                                                        <cfquery name="feltec" datasource="#Request.MainDSN#">

                                                        INSERT INTO user(

                                                        username,

                                                        firstname,

                                                        lastname,

                                                        email,

                                                        password,

                                                        retypepassword,

                                                        phone,

                                                        address,

                                                        dateofbirth,

                                                        sex,

                                                        optionphone

                                                        )

                                                        VALUES(

                                                        <cfqueryparam value="#Form.username#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.firstname#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.lastname#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.email#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.password#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.retypepassword#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.phone#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value="#Form.address#" cfsqltype="cf_sql_varchar">,

                                                        <cfqueryparam value = '#form.dateofbirth#' cfsqltype = "cf_sql_date">,

                                                        '#Form.sex#',

                                                        <cfqueryparam value="#Form.optionphone#" cfsqltype="cf_sql_varchar">

                                                        )

                                                        </cfquery>

                                                        </cfif>

                                                      <!---End of database--->

                                                      • 24. Re: Felix Mayowa
                                                        haxtbh Level 4

                                                        What is the error you are getting? Cannot help further without that really.

                                                        • 25. Re: Felix Mayowa
                                                          felixm71880667 Level 1
                                                          can't cast [23,9,1993] to date value

                                                          That's the error i'm getting

                                                          • 26. Re: Felix Mayowa
                                                            Dave Ferguson Level 3

                                                            Please give us the full error.  It should say what line of the code is the issue.  You may need to go into the ColdFusion administrator and enable robust exception info under debugging and logging.

                                                            • 27. Re: Felix Mayowa
                                                              haxtbh Level 4

                                                              This is not a valid date format. Where are you getting this string from? I also notice in your code above, you have the same name / ids on all your select elements. This is incorrect, ids have to be unique for a start.

                                                              • 28. Re: Felix Mayowa
                                                                felixm71880667 Level 1
                                                                an't cast [9,9,1993] to date value
                                                                StacktraceThe Error Occurred in
                                                                /home/felix/Desktop/lucee/webapps/www/felix/page/form/reg.cfm: line 32
                                                                30: <cfqueryparam value="#Form.optionphone#" cfsqltype="cf_sql_varchar">
                                                                31: )
                                                                32: </cfquery>
                                                                33: </cfif>
                                                                34: <!---End of database--->

                                                                 

                                                                called from /home/felix/Desktop/lucee/webapps/www/felix/index.cfm: line 49
                                                                47:
                                                                48:
                                                                49: <cfinclude template="page/#url.page#"/>
                                                                50:
                                                                51: <script>

                                                                thats the full error

                                                                • 29. Re: Felix Mayowa
                                                                  felixm71880667 Level 1

                                                                  so how do i go about it in the select element.

                                                                  • 30. Re: Felix Mayowa
                                                                    BKBK Adobe Community Professional & MVP

                                                                        '#Form.sex#'

                                                                      <cfqueryparam value="#Form.sex#" cfsqltype="cf_sql_char">

                                                                    or

                                                                    <cfqueryparam value="#Form.sex#" cfsqltype="cf_sql_varchar">

                                                                     

                                                                    can't cast [23,9,1993] to date value

                                                                    That's the error i'm getting

                                                                    The error message is obvious enough. I think 23-09-1993 or 23/09/1993 would work.

                                                                    • 31. Re: Felix Mayowa
                                                                      felixm71880667 Level 1

                                                                      God Bless you all.

                                                                      i have found solution to my problem. I love you all

                                                                      • 32. Re: Felix Mayowa
                                                                        BKBK Adobe Community Professional & MVP

                                                                        felixm71880667 wrote:

                                                                         

                                                                        God Bless you all.

                                                                        i have found solution to my problem. I love you all

                                                                        I am glad to hear. Could you please describe here your solution here. It will help someone else in future. Thanks for the love.

                                                                        • 33. Re: Felix Mayowa
                                                                          felixm71880667 Level 1

                                                                          <cfif isDefined("form.save")> 

                                                                               <cfset felix = "#form.dob#" />

                                                                                 <cfset #form.dob# = "#felix#" />

                                                                                 <cfdump var="#form#"/>

                                                                            </cfif>

                                                                           

                                                                          <!---Date--->

                                                                          <div class="form-group">

                                                                            <input class="form-control" type="date" name="dob">

                                                                            </div>

                                                                          <!---End of Date--->

                                                                           

                                                                          that's how i corrected it

                                                                          • 34. Re: Felix Mayowa
                                                                            Carl Von Stetten Adobe Community Professional & MVP

                                                                            felixm71880667,

                                                                            A couple of things to note. First - in your original form code, as others stated, you had three select inputs that had the same name.  When a form with multiple inputs with the same name is submitted to ColdFusion, the values of those inputs are automatically combined into a comma-delimited list in a single FORM variable (as you were seeing).  There is an application-level setting in ColdFusion 11 that will instead turn the values of multiple same-named inputs into an array instead of a list.

                                                                             

                                                                            Second, it appears that you are actually running Lucee and not Adobe ColdFusion (at least that is what I see in the post where you showed the error message).  While general CFML questions will likely be answered in this forum, keep in mind the forum is intended for users of Adobe ColdFusion.  Lucee has it's own community support via the Lucee Google Group.

                                                                             

                                                                            -Carl V.