Pass form value from PHP page to ASP.Net

Hi,
A Customer has a site developed in PHP and hosting on a remote server with a basic form.  I need to have some of this data posted to a different web site on a second server running an ASP.net site.

I discounted cookie / session values and cant use query string values in the URI due to the length and contents of the data.

Any suggestions?
MoliorAsked:
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.

Ray PaseurCommented:
Yes, you can use POST to send the data.  Show us what you've tried so far, and I'll try to find an example of a POST from one page to another. ~Ray
0
Ray PaseurCommented:
Sample showing how to configure headers and post array.  HTH, ~Ray
<?php // RAY_cross_post.php
 
// URL OF THE WEB SITE WE WANT TO POST TO
$url	= "www.yoursite.com";
 
// SCRIPT OF THE WEB SITE WE WANT TO POST TO
$scr	= "/process.asp";
 
 
 
 
// PUT UP OUR FORM TO COLLECT SOME DATA
if (empty($_POST)) { ?>
Enter Something Here:
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="my_field_1" />
<input type="text" name="my_field_2" />
<input type="submit" name="_submit" value="Go!">
</form>
<?php die(); }
 
 
 
// READ MY POST DATA, ADD OR DELETE ANY NEEDED FIELDS
$postdata	= '';
$req		= 'cmd=yes'; // THIS IS ARBITRARY - ADDED TO ALL INPUT DATA
foreach ($_POST as $key => $value) {
	$postdata	.= "\n $key = $value ";			// SAVE THE COLLECTION FOR LATER USE
	if (substr($key,0,1) == '_') continue;			// ARBITRARY - OMIT ALL FIELDS STARTING WITH UNDERSCORE
	$value		= urlencode(stripslashes($value));	// ENCODE FOR CROSS POST
	$req		.= "&$key=$value";			// APPEND TO THE CROSS-POST STRING
}
 
// POST TO OUR CHOSEN WEB SITE AND SCRIPT
$header .= "POST $scr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ($url, 80, $errno, $errstr, 30);
 
 
// TEST FOR SUCCESSFUL POST OPEN
if (!$fp) { // HTTP ERROR PROCESSING
	die("HTTP ERROR fsockopen failed \n\n URL=$url \n\n SCR=$scr \n\n ERRNO=$errno \n\n ERRSTR=$errstr \n\n");
}
 
// HTTP OPEN - WRITE HEADER AND REQUEST
fputs ($fp, $header . $req);
 
// HTTP OPEN - READ SCRIPT RESPONSE, IF ANY
$script_reply 	= '';
$script_headers	= '';
while (!feof($fp)) {
	$script_reply	= fgets ($fp, 1024);
	$script_headers	.= $script_reply;
}
fclose ($fp);
 
// IF NEEDED, PROCESS THE INFORMATION FROM THE OTHER WEB SITE
var_dump($script_headers);
var_dump($script_reply);

Open in new window

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
Web Applications

From novice to tech pro — start learning today.