?
Solved

Multiple Destination form submit - Vitally URGENT.

Posted on 2006-03-22
4
Medium Priority
?
323 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Mark Gilbert
  • 3
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16257114
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
 
LVL 18

Author Comment

by:Mark Gilbert
ID: 16257307
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
 
LVL 49

Expert Comment

by:Roonaan
ID: 16257370
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
 
LVL 49

Accepted Solution

by:
Roonaan earned 2000 total points
ID: 16257378
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question