passing post data using cURL requires that the name of the input. However, I was wondering how can you do it if the input was not assigned a name?
curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" http://www.formpost.com/getthis/post.cgi
passing post data using cURL requires that the name of the input. However, I was wondering how can you do it if the input was not assigned a name?
curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" http://www.formpost.com/getthis/post.cgi
You don't. GET queries and POST data both come in name=value
form. The only exception is if you change a form's submission encoding to enctype="multipart/form-data"
because you have a file upload control.
See http://www.cs.tut.fi/~jkorpela/forms/file.html#enctype for more information:
The HTML specification defines two possible values for
enctype
:
enctype="application/x-www-form-urlencoded"
(the default)
This implies a simple encoding which presents the fields asname=value
strings separated by ampersands (&
) and uses some special “escape” mechanisms for characters, such as%28
for the “(” character. It’s confusing if people try to read it—it was meant to be processed by programs, not directly read by humans!
enctype="multipart/form-data"
This implies that the form data set is encoded so that each form field (more exactly, each “control”) is presented in a format suitable for that field, and the data set as a whole is a multipart message containing those presentations as its components. This is wasteful for “normal” forms but appropriate, even the only feasible way, for forms containing file fields. The multipart structure means that each file comes in a nice “package” inside a larger package, with a suitable “label” (content type information) on the inner “package.” This type was originally defined in RFC 1867 but it is also discussed in RFC 2388 (see notes on the RFCs later).
There is an option CURLOPT_POSTFIELDS
. It lets you set the POST data either as an associative array or as a string. So, you would need to use the latter option.