Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Azadi Saryev,
please see the code below and advise if this is correct. As you probably know, i am very new at this, so any detailed explanations would be helpful.
this is at the very top of my .cfm page (website homepage)
( the name of the table and column are 'Emails' )
<cfif structkeyexists(form, 'submit') AND len(trim(form.Emails))>
<CFQUERY NAME="insertFormData" DATASOURCE="blueskeleton">
INSERT INTO Emails (Emails)
VALUES ('#form.Emails#')
</CFQUERY>
</cfif>
webpage code here.....
<!--- form for email addresses --->
<cfform> <strong>
<center>
Monthly Newsletter
</center>
</strong> <small> <em>
<center>
enter your email below
</center>
</em></small>
<center>
<cfinput type="text" name="Emails" autosuggest="true" maxlength="35" typeahead="no" showautosuggestloadingicon="true">
<cfinput type="button" name="Submit" value="Submit">
</center>
</cfform>
<!--- form ends here --->
web page ends here....
thanks!
jon
Copy link to clipboard
Copied
Copy link to clipboard
Copied
still alittle confused on my first cfm attempt. please quickly review the code below and advise why this is not working.
I have 2 files, my homepage, which is my index.cfm file and the component, which is Emails.cfc .... I am just trying to collect email addresses from visitors to my site on the homepage.
index.cfm code:
<cfif IsDefined("form.Emails")>
<cfinvoke
component="blueskeleton.cfc.Emails"
method="insertEmails">
<cfinvokeargument name="formData" value="#form#"/>
</cfinvoke>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--- my webpage code is here .. my index.cfm --->
<!--- form for email addresses --->
<cfform> <strong>
<center>
Monthly Newsletter
</center>
</strong> <small> <em>
<center>
enter your email below
</center>
</em></small>
<center>
<cfinput type="text" name="Emails" autosuggest="true" maxlength="35" typeahead="no" showautosuggestloadingicon="true">
<cfinput type="button" name="Submit" value="Submit">
</center>
</cfform>
<!--- form ends here --->
<!--- web page ends --->
and here is the Emails.cfc file code..
<cfcomponent>
<cffunction>
<cffunction name="insertEmails" access="public" returntype="void">
<cfargument name="formData" type="struct" required="yes">
<cfquery datasource="blueskeleton">
INSERT INTO Emails
(Emails)
VALUES
('#formData.Emails#')
</cfquery>
</cffunction>
</cfcomponent>
It does not work because when i hit submit, the page does nothing and no email is added to my MySQL database. I have the database setup correctly, i am confident it is something that i am doing incorrectly with the code above...
thanks fora any help with this.