【问题标题】:Submit form method POST to another site from my site and fetch the remote results从我的站点提交表单方法 POST 到另一个站点并获取远程结果
【发布时间】:2016-12-07 09:09:45
【问题描述】:

我有我的网站 example.com,在我的网站中我有一个指向另一个网站的 web html 表单,因此结果当前显示在另一个网站中。

我想用 PHP 或其他东西从其他网站获取结果并在我自己的网站上显示结果,问题是表单必须在 method=Post 中提交,所以我看不到任何方法来获取结果。

有什么想法吗?

这是从我的站点到目标远程站点的 html 表单

<form action="http://consultawebvehiculos.carabineros.cl/index.php" 
name="form1" id="control" method="post">
<input type="hidden" name="accion" value="buscar">
<table id="SEARCH">
<tr><td class="REGISTRATION">
<input name="txtLetras" type="text" class="PLATE" maxlength="2">
</td><td class="SEP">°</td>
<td class="REGISTRATION">
<input name="txtNumeros1" type="text" class="PLATE" maxlength="2">
</td><td class="SEP">°</td>
<td class="REGISTRATION">
<input name="txtNumeros2" type="text" class="PLATE" maxlength="2">
</td></tr></table>
<input type="submit" value="GET RESULT" ></form>

【问题讨论】:

  • 为什么需要从另一个网站获取form 的结果?在提交form 之前,您可以访问form 数据。

标签: javascript php jquery html css


【解决方案1】:

你可以使用 $_POST['name of the input field'] http://consultawebvehiculos.carabineros.cl/index.php 。代码将是这样的:

$txtLetras== $_POST['txtLetras'] ;
 echo $txtLetras ; 

【讨论】:

  • 您能解释一下并举个例子吗?请记住,我从中获取结果的目标页面不是我的网站...
【解决方案2】:

编写一个服务器端 (php) 脚本作为代理。它将接收表单输入,将其发布到外部站点,接收来自外部站点的响应并显示响应。

然后您可以通过 ajax 发布到此脚本(在您的服务器上)并显示它返回的响应。

参考——PHP + CURL

PHP + curl, HTTP POST sample code?

Passing $_POST values with cURL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多