Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form Id with PHP + cURL

Posted on 2004-10-12
12
Medium Priority
?
564 Views
Last Modified: 2012-06-27
Hi,

I hope someone can help me with a small info.


I 'm trying to post following form data using cURL to IIS server (not under my control), but remote site is obviusely checking »form id«.
Question is how to send »form id« via cURL?

HTML
<form  id=admin action="www.somesite.com/test.asp" method="POST">
<input type="hidden" name="var1" value="1">
<input type="hidden" name="var2" value="2">
<input type="hidden" name="var3" value="3">
    <input type="submit" name="button" value="push">
</form>

PHP + cURL
<?
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL," www.somesite.com/test.asp");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "var1=1&var2=2&var3=3id=admin");

curl_exec ($ch);
curl_close ($ch);
?>


Any Ideas?

Thx, Robert
0
Comment
Question by:Whisky
  • 4
  • 3
  • 3
12 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12286075
What is missing in your postfield is the button=push
try this:

curl_setopt($ch, CURLOPT_POSTFIELDS,
            "var1=1&var2=2&var3=3&button=push");
0
 

Author Comment

by:Whisky
ID: 12286230
Hi hernst42,

I tried that option too, but no luck.
My wild guess would be that remote site is using "Request.Form("id")" method for checking
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12286364
I have used you example code and looked into the transmitted HTTP-protocol there where only those 4 variables sent to the webserver:

var1=1&var2=2&var3=3&button=push
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:frugle
ID: 12286565
Request.Form("id")

would return "admin" if you also had <input type="hidden" name="id" value="admin">

your wild guess is quite inaccurate. <form id= ID is used by Javascript in validation, e.g. document.id.submit(); to call the submit routine on that particular form.

The server is more likely to be picking up the referring page and throwing your input out.

Mike
0
 

Author Comment

by:Whisky
ID: 12286719
My HTML example code IS working,

and PHP+cURL is NOT, I'm not very familiar with .asp so my guess is / can be inaccurate.

How to solve the problem is basic question ... any more ideas?
0
 
LVL 10

Expert Comment

by:frugle
ID: 12286779
var1=1&var2=2&var3=3id=admin

should be

var1=1&var2=2&var3=3&id=admin
                                   ^ note
Mike
0
 

Author Comment

by:Whisky
ID: 12288213
Tried ... var1=1&var2=2&var3=3&id=admin ... NOT working

I'm posting to .asp page (which structure or code I have not seen), so I can not say how it functions or what it checks, but never the less HTML example (resides on my server so the referer can not be a problem) which I posted a few posts up ... is working, So only difference between HTML example and cURL is "form id", also if I throw "form id" out, HTML example does not work anymore.
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 1000 total points
ID: 12288560
You might try a network sniffer which log the packets send by your browser to that asp-page and see which information is posted to the asp page, then check what you curl-request is send and what might be missing. (For Windows I don't know such a tool. On Unix use ethereal e.g.)
0
 
LVL 10

Assisted Solution

by:frugle
frugle earned 1000 total points
ID: 12288722
http://www.htmlhelp.com/reference/html40/attrs.html#id

The ID attribute uniquely identifies an element within a document. To my knowledge it is not passed by the browser.


The problem is more likely to be cURL, and the fact that it sends data as application/x-www-form-urlencoded

Is it possible to give more information on the server that you are communicating with and the variables you are sending?

Mike
0
 
LVL 10

Expert Comment

by:frugle
ID: 12482943
no objections here, though would be nice to know if the questioner actually solved the problem with our advice.

Mike
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question