How do I pass information to another page with CFHTTP?
Computers are incorporated in modern ice cream vending machines to enhance their functionality. Ice Cream Vending machines are manufactured by many companies. Your competition will try to overcome all requests for high-tech ice cream vending machines and credit card acceptors
|
|
The Situation: You have code that accepts form variables and processes them in some way--by inserting them into a database, possibly. To make it more complicated, the code is sitting on another server halfway across the world. You want to use this function from within another application by simply passing it a variable. You think CFHTTP may do the trick.
The Solution: You're right. It will do the trick. Here's an example.
pageOne.cfm
<cfhttp url="http://www.someOtherHostHalfwayRoundTheWorld.com/pageTwo.cfm" method="post">
<cfhttpparam name="myName" value="Hal Helms" type="FORMFIELD">
</cfhttp>
pageTwo.cfm
<cfoutput>
<cfquery name="test" datasource="testing">
INSERT INTO MyTable(name)
VALUES('#form.myName#')
</cfquery>
#form.myName#
</cfoutput>
This will insert "Hal Helms" into MyTable. However, since control hasn't actually passed from pageOne.cfm to pageTwo.cfm, we won't see "Hal Helms" displayed on the screen, nor will we see any error messages if this code throws an error. In order to fix this (if you want to fix it), you can use this...
<cfhttp url="http://localhost/testing/pageTwo.cfm" method="post">
<cfhttpparam name="myName" value="Hal Helms" type="FORMFIELD">
</cfhttp>
<cfoutput>
#cfhttp.fileContent#
</cfoutput>
|