Drupal:将数据转发到另一台服务器的简单形式
我需要在我的 Drupal 网站中添加一个带有表单的页面。该表单应提交到另一台服务器(在此类服务器上有一个 php 脚本准备接收它)。
因此,我不需要任何数据库更新,只需一个将用户插入的数据转发到另一个域的页面。
你知道最简单的方法是什么吗?
谢谢
另外,我需要创建一个下拉菜单,其中包含国家/地区列表(以及每个国家/地区的区域)作为子菜单
I need to add a page with a form in my Drupal website. This form should be submitted to another server (there is a php script ready to receive it on such server).
So, I don't need any database update, just a page forwarding the data inserted by users to another domain.
Do you know what's the easiest way to do it ?
thanks
ps. Also, I need to create a drop down menu with a list of countries (and regions for each country) as submenu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我很惊讶没有人提到 hook_form_alter 并将
#action
设置为外部 URL。这将使表单直接发布到其他服务器(如果您可以控制它),您可以轻松重定向回来。比从服务器上发布要容易得多。另一种方法是iframe
另一个脚本并使用 target 属性(在$form['#attributes']['target'] = 'the_iframe'
>hook_form_alter)。然后你可以在提交后使用JS来“移动”页面。将 POST 上传到 iframe,您也可以查看该 JS。 如何发布到 iframe? 讨论 iframe 和表单。I am surprised noone mentioned hook_form_alter and setting
#action
to an external URL. This will make the form post directly to the other server if you have control of it you can easily redirect back. Lot easier than POSTing from your server. Another way would be toiframe
the other script and use the target attribute (set$form['#attributes']['target'] = 'the_iframe'
inhook_form_alter
). Then you can use JS to 'move' the page after the submit. Upload POSTs to an iframe, you can look into that JS as well. How do you post to an iframe? discusses iframes and forms.在表单中,您可以设置
# action
到您想要的任何 URL。它将发布到该网址。如果您需要 GET 而不是 POST,您还应该设置#method
。}
In your form, you can set
#action
to whatever URL you want. It will post to that url. If you need a GET, instead of a POST, you should also set the#method
.}
您可以使用常用的验证内容创建一个常规的 drupal 表单,而不是将日期放入数据库中,而是将其发送到其他站点(通过 post 或 get 或其他方式)。
You could create a regular drupal form with the ususal validation stuff and instead of putting the date into the DB send it over to the other site (via post or get or whatever).
要在您自己的自定义表单实现中 POST 到外部 URL,或使用 hook_form_alter() 将另一个提交处理程序添加到现有表单,同时不显示请求,您将需要使用 drupal_http_request() 发送服务器端 http 请求。请参阅:
http://www.drupaler。 co.uk/blog/validating-submitting-forms-other-websites-drupal/428
要使用 webform 模块完成此操作,您需要上面学到的知识以及类似以下内容:
在 D6 /网络表格< 3
http://drupal.org/node/543674#comment-2499674< /p>
在 Drupal 7/Webform 3 中
http://www.midwesternmac.com/blogs/ jeff-geerling/integrate-webform-3x-paypal
To POST to an external URL in your own custom form implementation or using hook_form_alter() to add another submit handler to an existing form, while not showing the request you will want to use drupal_http_request() to send a serverside http request. See this:
http://www.drupaler.co.uk/blog/validating-submitting-forms-other-websites-drupal/428
To accomplish this with the webform module you'll need what you learned above and something like the following:
In D6 /Webform < 3
http://drupal.org/node/543674#comment-2499674
In Drupal 7/Webform 3
http://www.midwesternmac.com/blogs/jeff-geerling/integrate-webform-3x-paypal