Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having a problem on CFHTTP

Status
Not open for further replies.

edeaux

Programmer
Mar 7, 2003
16
0
0
PH
I made two scripts namely cfhttpSender.cfm and cfhttpRecv.cfm. The first script (cfhttpSender.cfm) will invoke cfhttp to post myName form field to the second script (cfhttpRecv.cfm). The second script will get form variable passed by first script and execute a query that inserts the value passed on it to a table. Anyway the purpose of inserting the value is to know if the form field is posted to the second script.
I ran it and checked the table if the form field value is added to the table and no record has been added to table. I don't know what causes this. What are the requirements or parameters in using cfhttp?

Thanks,

Edwin




The following are the codes:

cfhttpSender.cfm

<cfhttp url=&quot;cfhttpRecv.cfm&quot; method=&quot;post&quot;>
<cfhttpparam name=&quot;myName&quot; value=&quot;Edwin&quot; type=&quot;FORMFIELD&quot;>
</cfhttp>


cfhttpRecv.cfm

<cfquery datasource&quot;test&quot;>
INSERT INTO tblNames (Name) VALUES ('#form.myName#')
</cfquery>


 
I think the CFHTTP is being used correctly...

the problem might be that your insert on the receive page is pulling an error, and you'll never know since you don't ever actually see the page (where CF would output the error message).

Two things that I can see right off that might cause errors are:
a) there's no = between your datasource parameter and the value. Should be
Code:
datasource
Code:
=
Code:
&quot;test&quot;
... but that might have just been a typo in the translation to this forum.

b) you don't specify a name for the query. &quot;name&quot; is listed as a required parameter for CFQUERY... even if you're only doing an insert. Give it a name.

Finally, if neither of the above fix the problem, temporarily create a FORM (either on the same page or a new page) with a field named &quot;myName&quot; that actually submits to cfhttpRecv.cfm. What this will do is allow cfhttpRecv.cfm to actually render and you'll be able to see any errors it generates. Fix the errors until the insert runs correctly off of a true form submit... then go back to using CFHTTP, and it should work too (at least the way you've written it above).

-Carl
 
Carl,

Thanks for the replying.
Sorry for posting wrong syntax on cfquery. I ran cfhttpRecv.cfm and a record was added to the table. But when I ran cfhttpSender.cfm no record was added. I followed on what you were posting like create a form (I commented cfhttp in cfhttpSender.cfm) and submit it to cfhttpRecv.cfm. It was working properly. MyName value record was added to the table.

Is there a setting in coldfusion admin in order to work properly the cfhttp?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top