Link to home
Start Free TrialLog in
Avatar of Whisky
Whisky

asked on

Form Id with PHP + cURL

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
Avatar of hernst42
hernst42
Flag of Germany image

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");
Avatar of Whisky
Whisky

ASKER

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
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
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
Avatar of Whisky

ASKER

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?
var1=1&var2=2&var3=3id=admin

should be

var1=1&var2=2&var3=3&id=admin
                                   ^ note
Mike
Avatar of Whisky

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
no objections here, though would be nice to know if the questioner actually solved the problem with our advice.

Mike