473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help With CURL And GET Forms

I have used curl_setopt($ch, CURLOPT_POST, true); and curl_setopt($ch,
CURLOPT_POSTFIELDS, $data); on post forms to retrun results, but what
about a GET Form Method? How do you deal with these with curl? The
same commands?

The particular instance I am dealing with is a store locator and it is
not as easy as just calling the url with the variables becasue it runs
some script behind the scene that does a bunch of calculations for
calculating the lat. and lon. of the store so it can call a mappoint
map. After the form submission the url is a mess and pretty customized
to the zip code searched with lat and lon.

Here is an example of the form action:
<form Method="GET"
Action="http://go.mappoint.net/ccc/Geocode.aspx?brand=h&amp;FC=ccc&amp;FC=ccc"
Name="OutsideUS">

Here is an mocked up example of a resulting URL after the form
submission:

http://go.mappoint.net/ccc/PrxResult...=isccc&brand=a

How would I deal with this in curl? Your help is much appreciated.

Thank you!

Dec 1 '06 #1
1 1818
devranger wrote:
I have used curl_setopt($ch, CURLOPT_POST, true); and curl_setopt($ch,
CURLOPT_POSTFIELDS, $data); on post forms to retrun results, but what
about a GET Form Method? How do you deal with these with curl? The
same commands?

The particular instance I am dealing with is a store locator and it is
not as easy as just calling the url with the variables becasue it runs
some script behind the scene that does a bunch of calculations for
calculating the lat. and lon. of the store so it can call a mappoint
map. After the form submission the url is a mess and pretty customized
to the zip code searched with lat and lon.

Here is an example of the form action:
<form Method="GET"
Action="http://go.mappoint.net/ccc/Geocode.aspx?brand=h&amp;FC=ccc&amp;FC=ccc"
Name="OutsideUS">

Here is an mocked up example of a resulting URL after the form
submission:

http://go.mappoint.net/ccc/PrxResult...=isccc&brand=a
>
How would I deal with this in curl? Your help is much appreciated.

Thank you!
Hi,

I think just assembling the URL should do the trick.
So just add all name/value pairs you have to the url.
eg:
$baseURL = "http://go.mappoint.net?";
// assuming you have your info in an assoc-array:
$myNameValues = array(
"LOC" ="23.327467234",
"CT" ="34.879327689"
);

// urlencode all values
$urlEncodedParts = array();
foreach ($myNameValues as $key =$value){
$urlEncodedParts = $key."=".urlencode($value);
}

// add to baseurl
$baseURL .= implode("&",$urlEncodedParts );
Then just use the baseurl in CURL without POST-options.

(Not tested)

Regards,
Erwin Moller
Dec 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Conrad F | last post by:
Hi, If any Microsoft people are listening.... Are there any plans for the new web language called "Curl" to be supported in .NET (ASP.NET)? I ask as Curl represents the first step to true OO...
27
by: Scott | last post by:
I've been trying to come up with a way to ensure user input is coming from the form on my site, and not auto-submitted from elsewhere, and I don't want to use the "enter the code shown in the...
0
by: info | last post by:
Dear all, is the first time that I use SOAP, and i must say that i'm having several problems. this is SOAP message that expects the server =================XML EXPECTED FROM THE...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
6
by: admin | last post by:
Hi, I have a mysql box that has a private network ip. The old developer was running our web server on this machine but the company since retired the box and it is in a closet, still running, but...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
1
by: devranger | last post by:
Hello, I am in the process of learning PHP CURL and in doing some test examples I am having some issues with CURL that I do not fully understand. I am doing a test to use CURL to post and return...
9
by: devranger | last post by:
I am using the below CURL Function and can not figure out why it is not retruning the results from the post. Can anyone take a look and tell me what I may be doing wrong? I am just not seeing...
1
by: c1pkw | last post by:
Hi there, I’m having a real heap of trouble with PHP and cURL My aim is to use this code (or something like it) to submit 2 fields to a remote server (using GET) and receive back 6 fields...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.