2
<form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl">

我正在创建一个从 aweber 提交的应用程序,但我还需要输入字段来存储在数据库中。但是我还需要这些输入来在我的最后存储 inv 数据库,因为我们不能有两个动作,所以我怎样才能在 PHP 中获取它们。

4

2 回答 2

1

我们可以在 CURL 的帮助下做到这一点

    public function signup()
{
    $fields_string='';
    $ch = curl_init('http://www.aweber.com/scripts/addlead.pl');
    $fields = array(
        'name' => $this->input->post('name'),
        'email' => $this->input->post('email'),
        'meta_web_form_id' => '1122',
        'meta_split_id' => '',
        'listname' => 'abc',
        'meta_redirect_onlist' => '',
        'meta_adtracking' => 'My_Web_Form',
        'meta_message' => '1',
        'meta_required' => 'name,email',
        'meta_forward_vars' => '0',
    );
    foreach($fields as $key=>$value)
    {
        $fields_string .= $key.'='.$value.'&';
    }
    rtrim($fields_string,'&');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch,CURLOPT_POST,count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $returned = curl_exec($ch);
    $this->register_user($fields);
}

$this->register_user($fields); // 当我们将姓名和电子邮件传递给该函数时,此函数将在我的数据库中存储值

于 2017-06-08T09:34:29.290 回答
1

您可以使用 javascript 或 jquery

当您单击提交按钮时,您可以将表单数据发送到您的 url,也可以将该数据发布到您的控制器,然后您可以将其插入数据库。

<form id='myform' method='post'>
<input />
<input />
<button id='submit'></button>
</form> 
$('#submit').on('click', function(){
  $.ajax({
      'dataType': 'json',
      'type': 'POST',
      'data': $('#myform').serialize(),
      'url': 'http://www.aweber.com/scripts/addlead.pl',
       success: function (data) {
         //what ever you want to do with the return data
       }
   })
  $.ajax({
      'dataType': 'json',
      'type': 'POST',
      'data': $('#myform').serialize(),
      'url': 'your code igniter controller url',
       success: function (data) {
         //what ever you want to do with the return data
       }
   })
})
于 2017-04-27T06:50:36.657 回答