0

How do I pass all form data function to third party URL. Suppose my third URL is

`http:\\www.abletoaccess.com\form\request` 

For the security reason I don't want to access this URL in form action method or I don't want to post direct form data. I want when I submit the form all data comes in my function and redirect to third party URL with post data and added more parameters.

Any help will be appreciated!!!!

Mehul Kuriya
  • 608
  • 5
  • 18
sandip kakade
  • 1,346
  • 5
  • 23
  • 49

4 Answers4

1

You can handle the request by your controller and then show view and auto-submit it to external url.

    <div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Page is loading...
                </div>
                <div class="panel-body">
                    {!! Form::open(['url' => $externalUrl, 'method' => 'POST', 'class' => 'form-horizontal', 'id' => 'my-form']) !!}
                        @foreach ($fields as $key => $value)
                            {{ Form::hidden($key, $value) }}
                        @endforeach
                        {{ Form::hidden('signature', $signature) }}
                    {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    document.getElementById('my-form').submit();
</script>
xAoc
  • 3,448
  • 3
  • 23
  • 36
1

Try Following Code:

<form method="post" action={{ action('Controller@method') }}>

<input type="submit" value="add">
</form>

in controller file write below code :

public function method(Request $request)
{
     Redirect::away('external url')->withInputs(Input::all());
}

Laravel 5: how to redirect with data to external resource form controller

Community
  • 1
  • 1
Sujal Patel
  • 592
  • 2
  • 5
  • 14
0

First of all, this seems not to be Laravel specific issue.

Second, you need to check CURL function in PHP.

PHP CURL

Codemole
  • 3,069
  • 5
  • 25
  • 41
0

If you can, install Guzzle client that helps with these things.

You can pass the client to your controller and do a post request to another URL like this:

public function someMethod(GuzzleHttp\Client $client)
{
    $client->post('http:\\www.abletoaccess.com\form\request', [
        'form_params' => [
            'param1' => 'something',
            ...
        ]
    ]);
}
Technomad
  • 317
  • 5
  • 13