Co-registration on two different sites

135 views Asked by At

I'm trying to do co-registration, i.e. register on the original site first, then register the same form values to an external site.

I am looking for a clear way to do it, but without displaying an additional form with the values already populated.

I could get the form values from the original form using the following, but I am not sure it is the best way of doing it.

$.ajax({
  type: 'POST',
  dataType: 'JSON',
  data: {param1: $('input#param1').val(), param2: $('input#param2').val()},
  url: 'url to post to',
  success: (your success callback function goes here)
})

Really I just wanted to know if there is another way, but since all I have from the other site is the URL to send the data, jQuery is the only way I can think of — just want to know if anyone has another way of doing it seamlessly, without jQuery?

2

There are 2 answers

2
Herbert On BEST ANSWER

Your situation is similar to the scenario in this tutorial: Execute a HTTP POST Using PHP CURL. Also see the first comment on that page which may or may not be relevent here:

Your idea is simple enough tho if you’re going to be continually working with this remote database with limited access (are you working with a 3rd party?) you might want to use something a little more standard like SOAP or REST so that you can have error checking, etc.

Since you didn't give any details about your specific needs, I can't give any code that's relevant to your situation.

1
Josh P. On

Maybe try cURL:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/page?variable1='.$variable1.'&variable2='.$variable2);
$return = curl_exec($ch);

This should allow you to dynamically build a URL string that contains all of the variables for submitting to the registration page at the second location.