cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Error in my POST request?

From: Rocco <groovezone_at_gmx.de>
Date: Thu, 27 Apr 2006 10:09:10 +0200

Dear mailing list,

I'm trying to post data of the following form

<form method="post" action="index.php?nav=main&action=buy&shopid=123456">
<input type="text" maxchars="3" name="amount" value="1" />
<input type="submit" value="buy" />
</form>

using the following code

$BASEURL = 'http://www.....com';
$URL = 'index.php?nav=main&action=buy&shopid=123456'; // form-action
$fields = 'amount=100';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $BASEURL.$URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);

The resulting page should show a message that 100 pieces are bought,
but instead I get a message that I'm already logged in - as if I've
tried to login a secont time.

If index.php is called without the nav/action params it shows the login form

<form method="post" name="loginform" action="index.php">
<input type="text" name="loginname" value="" id="loginname" />
<input type="password" name="loginpwd" value="" id="loginpwd" />
<input type="submit" name="login" value="Login" />
</form>

but in this case I used 'index.php?nav=main&action=buy&shopid=123456'
- any ideas why the website gets my request wrong?

Maybe something about the submit button with no name? (<input
type="submit" value="buy" />)
Firefox shows it under Page Info -> Forms -> Fields together with
amount, which value I send with $fields - but how to send the value
"buy" for the button with no name?

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-04-27