Haisam Hameed
Haisam Hameed

Reputation: 63

i am creating application where submitting from to aweber but i also need input fields to store on db

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

I am creating an application where submitting from to aweber but I also need input fields to store on db. But I also need that inputs to store inv database at my end how can I get them in PHP as we can't have two actions.

Upvotes: 2

Views: 155

Answers (2)

Haisam Hameed
Haisam Hameed

Reputation: 63

We can do this with the help of 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); // This function will store values in my database as we are passing name and email to that function

Upvotes: 1

Yasitha
Yasitha

Reputation: 911

You can use javascript or jquery

when your submit button clicked you can send form data to your url and also you can post that data to your controller then you can insert it to the database.

<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
       }
   })
})

Upvotes: 1

Related Questions