Php cURL发送表单,但远程服务器未发布
我正在创建一个插件,使用PHP cURL自动发送表单。其结果良好,但服务器未发布表单。为什么呢Php cURL发送表单,但远程服务器未发布,php,html,curl,Php,Html,Curl,我正在创建一个插件,使用PHP cURL自动发送表单。其结果良好,但服务器未发布表单。为什么呢 //create array of data to be posted $post_data['full_name'] = $name; $post_data['email'] = $email; $post_data['subscription_type'] = 'E'; $post_data['id'] = $id; //traverse array and prepare data for p
//create array of data to be posted
$post_data['full_name'] = $name;
$post_data['email'] = $email;
$post_data['subscription_type'] = 'E';
$post_data['id'] = $id;
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection = curl_init($target_url);
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection).'-'.curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
这是代码的结果
Array (
[url] => http://www.remote-server.com/formcapture.php?v=28&w=29
[content_type] => text/html
[http_code] => 200
[header_size] => 180
[request_size] => 302
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.742828
[namelookup_time] => 0.015174
[connect_time] => 0.062791
[pretransfer_time] => 0.0628
[size_upload] => 75
[size_download] => 6122
[speed_download] => 8241
[speed_upload] => 100
[download_content_length] => 6122
[upload_content_length] => 75
[starttransfer_time] => 0.692776
[redirect_time] => 0
) 0-
这是我要寄的表格
<form class='subscription_form' id='subscription_form' method='POST' action='http://www.remote-server.com/formcapture.php?v=28&w=29'>
<div align='center'><center>
<p>Full name<br><input type='text' name='full_name' size='20'></p>
</center></div>
<div align='center'><center>
<p>E-mail address<br><input type='text' name='email' size='20'></p>
</center></div>
<input type='hidden' name='subscription_type' value='E'><div align='center'><center>
<p><input type='submit' value='Go »'></p>
</center></div>
<input type='hidden' name='id' value='360'>
</form>
全名
电子邮件地址
您是否尝试将cURL设置为返回响应标题
curl_setopt($curl_connection, CURLOPT_HEADER, 1);
这将返回您可以回显的头文件,并使用这些头文件查看其他服务器正在返回的内容
此外:
echo curl_getinfo($curl_connection, CURLINFO_HTTP_CODE);
应该带回HTTP响应代码,例如200 404 500等谢谢您的想法。结果只是一块空格。连接完成后,页面会自动重定向到php页面,条件由JS管理。现在,问题是没有给出条件结果。