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=ad min");
curl_exec ($ch);
curl_close ($ch);
?>
Any Ideas?
Thx, Robert
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=ad
curl_exec ($ch);
curl_close ($ch);
?>
Any Ideas?
Thx, Robert
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 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&butto n=push
var1=1&var2=2&var3=3&butto
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
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
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?
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=adm in
should be
var1=1&var2=2&var3=3&id=ad min
^ note
Mike
should be
var1=1&var2=2&var3=3&id=ad
^ note
Mike
ASKER
Tried ... var1=1&var2=2&var3=3&id=ad min ... 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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
no objections here, though would be nice to know if the questioner actually solved the problem with our advice.
Mike
Mike
try this:
curl_setopt($ch, CURLOPT_POSTFIELDS,
"var1=1&var2=2&var3=3&butt