We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Multiple Destination form submit - Vitally URGENT.

Mark Gilbert
Mark Gilbert asked
on
Medium Priority
356 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
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
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-
Mark GilbertSenior Performance Engineer

Author

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?
CERTIFIED EXPERT
Top Expert 2006

Commented:
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-
CERTIFIED EXPERT
Top Expert 2006
Commented:
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-

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.