How to trigger a php file on another server

Surely that’s the point of these lines:

$form_data = array(
'phone' => $sphone,
'email' => $semail
);

$str = http_build_query($form_data);

These, along with

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);

pass the form data through to do.php on server B. Your code on server B just isn’t using them. They’re passed through in the $_POST array just like they are in the form submit.

1 Like

Thanks alot @droopsnoot

I just got it working, by calling it using the $_POST method.

But if i set response return it does not work on but if echo it works.
Any explanation to it please

Sorry, I don’t know what you mean by that. Show the code that you are having trouble with.

CURL captures the output from your server-B script if you have the RETURNTRANSFER option set, so normally you would echo responses on the remote script, and they’ll appear in $output. If you need more than one response, you can build an array and json-encode it.

Thanks, @droopsnoot i just figured it out

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.