Welcome Guest, Not a member yet? Register   Sign In
submit button will do 2 things
#1

this project is on 2.1.2 version
the existing apps will post/submit form and save the input to database...

now i want to make the button will do post the same data to another webservice at another host... what should i do?

how to know what's the detail data posted ... i've found the code related to the page on folder [CI_ROOTDIR]/application/controller/production.php... CMIIW

Note: i have set the print($data) but nothing printed on the page... any pointer will be appreciated
Reply
#2

(10-18-2019, 12:00 AM)im not sure... is it like webhook?ceta Wrote: this project is on 2.1.2 version
the existing apps will post/submit form and save the input to database...

now i want to make the button will do post the same data to another webservice at another host... what should i do?

how to know what's the detail data posted ... i've found the code related to the page on folder [CI_ROOTDIR]/application/controller/production.php... CMIIW

Note: i have set the print($data) but nothing printed on the page... any pointer will be appreciated
Reply
#3

Without seeing the code we cannot help you.

Post the method that is getting the form post data.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(10-18-2019, 12:00 AM)ceta Wrote: this project is on 2.1.2 version
the existing apps will post/submit form and save the input to database...

now i want to make the button will do post the same data to another webservice at another host... what should i do?

how to know what's the detail data posted ... i've found the code related to the page on folder [CI_ROOTDIR]/application/controller/production.php... CMIIW

Note: i have set the print($data) but nothing printed on the page... any pointer will be appreciated


A simple way to do it is by sending the form through ajax, so you can send both requests without problem. The following jQuery plugin makes it very easy to send with ajax:

https://jquery-form.github.io/form/

You could for example insert the first group of data using the submit form and if the registration is done correctly then make the second request to insert the data using the callback:

Code:
<script>
     // wait for the DOM to be loaded
     $(function() {
       // bind 'myForm' and provide a simple callback function
       $('#myForm').ajaxForm(function() {
           //second request here
       });
     });
   </script>

A second variant could be to send the form without ajax, that is to say "in a normal way" and then in the action of the controller that handles the request make the second request using some tool like Guzzle for example:

https://github.com/guzzle/guzzle


PHP Code:
$response $client->request('POST''http://httpbin.org/post', [
    'form_params' => [
        'field_name' => 'abc',
        'other_field' => '123',
        'nested_field' => [
            'nested' => 'hello'
        ]
    ]
]); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB