如果页面中有 2 个表单域,有 2 个不同的提交按钮,我如何告诉 cURL 提交哪个表单?
例子
<form method="post" action="index.php">
<input type="text" name="age">
<input type="submit" name="agree">
<input type="submit" name="disagree">
</form>
到目前为止我的代码
//create array of data to be posted
$post_data['age'] = '5';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);