基于HTML的远程表单POST&使用php curl获取远程服务器HTML响应?

时间:2014-08-13 16:30:58

标签: php html forms curl

我正在制作镜像公开考试结果发布网站。我尝试了什么,用户会将他们的滚动信息提交到我的页面,我会将数据发布到原始服务器&将原始服务器响应恢复到我的网站。

这是我的HTML表单输入的ID -

    id="sr" name="sr"
    id="et" name="et"
    id="exam" name="exam"
    id="year" name="year"
    id="board" name="board"
    id="roll" maxlength="6" name="roll"
    input id="button2" name="button2" type="submit" value="Submit"
    id="button" name="Reset" type="reset" value="Reset"

在提交表单上,它会调用process.php

这是process.php的代码我试图使用curl& amp; php基于某些类但不工作。我不会卷毛,所以不要太了解它。

<?php
$post_data['sr'] = '';
$post_data['et'] = '';
$post_data['exam'] = '';
$post_data['year'] = '';
$post_data['board'] = '';
$post_data['roll'] = '';



foreach ( $post_data as $key => $value) 
{
    $post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);


$curl_connection = curl_init('http://remotehost/result.php');

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);

curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

$result = curl_exec($curl_connection);
//curl_close($curl_connection);
var_dump($result);

print_r(curl_getinfo($curl_connection));

?>

如何解决?

0 个答案:

没有答案