Multiple Destination form submit - Vitally URGENT.

Greetings Experts,

I have setup a form which is handled by a php script.

There are currently 4 fields:

Name, Email, Telephone, Password.

When the form is submitted, a user account record is created in a local database which is then used for future authentication and a thank you page is displayed.  However, I also need to send this information without the password to another site for legal optin mailing list handling.

How can I get this form to submit to the other site after I have done the database processing?

Many thanks for your help.

Ingwa
LVL 18
Mark GilbertSenior Performance EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
When you can submit to http-GET you can just use:

file_get_contents('http://remotesite.com/submit.php?name=a&ema');

Otherwise use CUrl.

-r-
0
Mark GilbertSenior Performance EngineerAuthor Commented:
Hi Roonan,

I don't have curl on my development server however it is on the testing server.  I suppose I could use that to develop the script.  Do you have any examples on how to impliment such a form or sample code?
0
RoonaanCommented:
When curl is not available you can also use a script like:

function get_remote($url, $query) {
  $parts = parse_url($url);
  $host = isset($parts['host']) ? $parts['host'] : 'localhost';
  $port = isset($parts['port']) ? $parts['port'] : 80;
  $path = isset($parts['path']) ? $parts['path'] : '/';

  $fp = fsockopen($host, $port, $errno, $errstr);
  if (!$fp) {
    return false;
  }

  fputs($fp, "POST ".$path." HTTP/1.0\r\n".
  "Host: ".$host."\r\n".
  "Content-length: ".strlen($strXML)."\r\n".
  "Content-type: text/xml\r\n".
  "Connection: close\r\n\r\n".
  $query."\r\n");

  $buffer = '';
  while (!feof($fp)) $buffer .= fread($fp, 64);
  fclose($fp);
  return $buffer;
}

Then use:

$server_response = get_remote('http://remote.com/submit.php', 'email=this&firstname=that');

-r-
0
RoonaanCommented:
Sorry, typo:

function get_remote($url, $query) {
  $parts = parse_url($url);
  $host = isset($parts['host']) ? $parts['host'] : 'localhost';
  $port = isset($parts['port']) ? $parts['port'] : 80;
  $path = isset($parts['path']) ? $parts['path'] : '/';

  $fp = fsockopen($host, $port, $errno, $errstr);
  if (!$fp) {
    return false;
  }

  fputs($fp, "POST ".$path." HTTP/1.0\r\n".
  "Host: ".$host."\r\n".
  "Content-length: ".strlen($str)."\r\n".
  "Content-type: text/xml\r\n".
  "Connection: close\r\n\r\n".
  $query."\r\n");

  $buffer = '';
  while (!feof($fp)) $buffer .= fread($fp, 64);
  fclose($fp);
  return $buffer;
}

Code was an upgrade on code from webtweakers xml lib.

-r-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.