Start the process of registering a site from an external site

I integrate logins for two separate sites. Each site uses its own database and user tables.

My question is: how can I execute a remote script through PHP, as if I were submitting a form to a website?

I want one site to execute a login script that launches an external login to the script system as part of its own login process. Should I set the necessary session cookies and redirect back to the current site?

I use Opencart and vBulletin.

thank

+5
source share
1 answer

Here's how to use cURL to request a POST:

//set POST variables
$fields = array(
    'firstname' => 'Joe',
    'lastname' => 'Smith'
);

//urlify the data for the POST
$fieldsString = join('&', array_map('urlencode', $fields);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, 'http://somewebsite.com');
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

// view the results
echo $result;
0
source

All Articles