简体   繁体   English

将表单数据从一种表单传送到另一种表单? 这可能吗?

[英]Carrying Form data from one form to another form? Is this possible?

I have a small affiliate network and one of my offers, I have a form for it where I am collecting page viewer data for my own records, I then want to post that data to ANOTHER form automatically so the people do not need to complete the same information twice. 我有一个小型的联盟网络,并且是我的一个报价,我有一个表格,用于收集自己的记录的页面查看器数据,然后我希望将该数据自动发布到ANOTHER表格中,这样人们就无需填写相同的信息两次。

How would I do this? 我该怎么做?

I googled for nearly an hour and couldn't find anything. 我用Google搜索了近一个小时,却找不到任何东西。

The page can be viewed here 该页面可以在这里查看

http://getthiscrazyoffer.com/jobs/index.php http://getthiscrazyoffer.com/jobs/index.php

There are two good ways to do this: 有两种很好的方法可以做到这一点:

Way one: switch your page to using AJAX. 方法一:将页面切换为使用AJAX。 You can make two AJAX requests: one to each PHP file. 您可以提出两个AJAX请求:每个PHP文件一个。

Way two: You can use the cURL plugin for PHP to make GET and POST requests automatically from the server; 方法二:您可以使用PHP的cURL插件自动从服务器发出GET和POST请求; thus you can send the data to the PHP file for the other form. 因此,您可以将数据发送到另一种形式的PHP文件。 In particular, for POST requests, you'll need to: 特别是,对于POST请求,您需要:

  1. Use $curl = curl_init(url) to generate a request 使用$curl = curl_init(url)生成请求
  2. use curl_setopt($curl, CURLOPT_POST, true) to make it a POST request 使用curl_setopt($curl, CURLOPT_POST, true)使其成为POST请求
  3. use curl_setopt($curl, CURLOPT_POSTFIELDS, $data) , where $data contains the form field values which the other form can retrieve via $_POST 使用curl_setopt($curl, CURLOPT_POSTFIELDS, $data) ,其中$data包含其他表单可以通过$_POST检索的表单字段值
  4. Use curl_exec to run the request. 使用curl_exec运行请求。

Depending on your need, the easier way to carry data to another page is through cookies. 根据您的需要,将数据携带到另一个页面的更简单方法是通过cookie。 If you are using jQuery, you may look at this page to see how cookies work: 如果您使用的是jQuery,则可以查看此页面以了解Cookie的工作方式:

How do I set/unset cookie with jQuery? 如何使用jQuery设置/取消设置cookie?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM