我想知道是否有人可以提供帮助。我有一个表单,提交时使用http post提交数据并请求网址。我在浏览器中显示了网址,但我希望用户能够自动重定向到生成的网址。
<form id="form_52393" class="appnitro" action="https://test.dekopay.com:3343/" method="post">
<div class="form_description">
<h2>Finance Application Form</h2>
Enter the course name, its price, the term of you finance and your deposit. You will then be redirected to an online application form to complete the process. Below is my form code.
</div>
<ul>
<li><label class="description" for="action">action</label>
<div><input id="element_9" class="element text medium" maxlength="255" name="action" type="hidden" value="credit_application_link" /></div></li>
<li id="li_5"><label class="description" for="Identification[api_key]">Identification[api_key] </label>
<div><input id="element_5" class="element text medium" maxlength="255" name="Identification[api_key]" type="hidden" value="be803c55eeaf79c89b6ff46ac6a9a039" /></div></li>
<li id="li_6"><label class="description" for="Identification[InstallationID]">Identification[InstallationID] </label>
<div><input id="element_6" class="element text medium" maxlength="255" name="Identification[InstallationID]" type="hidden" value="13161" /></div></li>
<li><label class="description" for="Identification[RetailerUniqueRef]">Identification[RetailerUniqueRef] </label>
<div><input id="element_7" class="element text medium" maxlength="255" name="Identification[RetailerUniqueRef]" type="hidden" value="test999" /></div></li>
<li id="li_1"><label class="description" for="Goods[Description]">Course Name </label>
<div><input id="element_1" class="element text medium" maxlength="255" name="Goods[Description]" type="text" value="" /></div></li>
<li id="li_10"><label class="description" for="Goods[Price]">Price </label>
<span class="symbol">£</span>
<input id="element_12_1" class="element text currency" name="Goods[Price]" size="10" type="text" value="" /> .
<label for="element_12_1">Pounds</label></li>
<li id="li_4"><label class="description" for="Finance[Code]">Finance Type </label>
<div><select id="element_4" class="element select medium" name="Finance[Code]">
<option selected="selected" value=""></option>
<option value="ONIF6">Interest Free Credit (0% APR) 6 month term</option>
<option value="ONIF9">Interest Free Credit (0% APR) 9 month term</option>
<option value="ONIF10">Interest Free Credit (0% APR) 10 month term</option>
<option value="ONIF12">Interest Free Credit (0% APR) 12 month term</option>
<option value="ONIF18">Interest Free Credit (0% APR) 18 month term</option>
<option value="ONIF24">Interest Free Credit (0% APR) 24 month term</option>
<option value="ONIF36">Interest Free Credit (0% APR) 36 month term</option>
<option value="ONIB12-12.9">Low Rate Credit (12.9% APR) 12 month term</option>
<option value="ONIB18-12.9">Low Rate Credit (12.9% APR) 18 month term</option>
<option value="ONIB24-12.9">Low Rate Credit (12.9% APR) 24 month term</option>
<option value="ONIB36-12.9">Low Rate Credit (12.9% APR) 36 month term</option>
<option value="ONIB12-24.9">Classic Credit (24.9(% APR) 12 month term</option>
<option value="ONIB18-24.9">Classic Credit (24.9(% APR) 18 month term</option>
<option value="ONIB24-24.9">Classic Credit (24.9(% APR) 24 month term</option>
<option value="ONIB36-24.9">Classic Credit (24.9(% APR) 36 month term</option>
</select></div></li>
<li id="li_12"><label class="description" for="Finance[Deposit]">Price </label>
<span class="symbol">£</span>
<input id="element_12_1" class="element text currency" name="Finance[Deposit]" size="10" type="text" value="" /> .
<label for="element_12_1">Pounds</label></li>
<li class="buttons"><input name="form_id" type="hidden" value="52393" /><input id="saveForm" class="button_text" name="submit" type="submit" value="Submit" /></li>
</ul>
</form>
下面是表单提交的php应该检索url并重定向用户但当前脚本运行并显示url而没有重定向。
<?php
$interface = "https://test.dekopay.com:3343/";
$postFields = Array(
"action" => "credit_application_link",
"Identification[api_key]" => "be803c55eeaf79c89b6ff46ac6a9a039",
"Identification[InstallationID]" => "13161",
"Identification[RetailerUniqueRef]" => uniqid(),
"Goods[Description]" => "",
"Goods[Price]" => "",
"Finance[Code]" => "",
"Finance[Deposit]" => "",
);
function httpPost($interface, $postFields)
{
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $interface);
curl_setopt($curlSession, CURLOPT_HEADER, 0);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlSession, CURLOPT_POST, 1);
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 180);
curl_setopt($curlSession, CURLOPT_FOLLOWLOCATION, 1);
return $curl_response = curl_exec($curlSession);
}
header('Location: ' . httpPost($interface, $postFields),True);
exit();
作为参考,我还提供了当前结果的屏幕截图。对不起,但我已经坚持了一个星期,并希望尽可能清楚。
在此先感谢您的帮助,我们非常感谢。