Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank You. but it is not explanatory. I read coldfusion developers guide 9. I cant apply it to a real practical
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
yes. i guess I'll go back to it again
Copy link to clipboard
Copied
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"
Copy link to clipboard
Copied
It would be extremely helpful if you posted the code that is causing your issue.
Copy link to clipboard
Copied
<!---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>
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
In addition to what fergusondj 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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks to everyone. I really appreciate this family.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
stii can't cast the date of birth to Date value. please help
Copy link to clipboard
Copied
<!---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--->
Copy link to clipboard
Copied
What error are you getting? Can you provide a sample of a date value coming from the form that isn't working?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
<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>
Copy link to clipboard
Copied
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--->
Copy link to clipboard
Copied
please help me
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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--->
Copy link to clipboard
Copied
What is the error you are getting? Cannot help further without that really.