对于我正在开发的系统,我需要以编程方式转到特定页面。在表单中填写一个字段(我知道输入元素的id和名称),提交并存储结果。
我确实有权从我也从中获取信息的网站上执行此操作。
我遇到的问题是,我相信脚本可以工作,但是因为外部表单的“操作”正在重定向到同一页面,并在表格中显示结果,它只是试图将我的个人网页重定向到同一目录,当然,这在我的服务器上不存在。
任何帮助表示赞赏,这是我到目前为止所拥有的:
//extract data from the post
extract($_POST);
//set POST variables
//URL IS SET, I HAVE JUST TOOK IT OUT OF THIS CODE SNIPPET
$urltopost = 'blahblah.com';
$datatopost = array (
's_3_2_5_0' => 0130016825566667, 'SWEFo' => 'SWEForm3_0', 'SWEField' => 's_3_1_0_0', 'SWENeedContext' => 'true',
'W' => 't', 'SWECmd' => 'InvokeMethod', 'SWEMethod' => 'SearchForLicence', 'SWESP' => 'false', 'SWEDIC' => 'false',
'SWEReqRowId' => '0','SWEView' => 'LDL+Licence+Query+View','SWEC' => '3','SWEBID' => '1363349905','SWEGHOTO' => 'true',
'SWETS' => '1363349913267', 'SWEApplet' => 'LDL+Query+Licences');
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$returndata = curl_exec ($ch);
echo $returndata;