5

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

My question is: how can I execute the remote script via PHP, as if I was submitting the form to the website?

I want the one site to execute the login script, which runs the external site login script as part of its own login process. Should I set the needed session cookies and redirect back to the current site?

I am using Opencart and vBulletin.

Thanks

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
  • 1
    Did You hear about CURL? Using CURL You can do a POST to an OpenCart's registration page to register the user on Your OC site...Same way from OC site to Your external site. This way You will have consistent user data tables. Then google for [Single Sign On](https://www.google.cz/#hl=en&q=opencart+single+sign+on) - I guess there is also an implementation for OpenCart... Try doing it Yourself or post a real question then... – shadyyx Mar 28 '13 at 11:17
  • @shadyyx +1 for Single sign on.. Janes.. look at how stackoverflow works with Open Auth login etc.. – TheBlackBenzKid Apr 02 '13 at 13:40

1 Answers1

0

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

//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;
chrislondon
  • 12,487
  • 5
  • 26
  • 65