The task seems simple. I want to use fsockopen to post variables to another page.
Just to give you an idea how I want it to work... This is being used for adding user accounts into two separate databases on different websites. The user fills out a form, the $_POST variables are used to create a user account in the main database, then I want to send those variables to another page (through fsocket) to setup the account on the secondary databse.
Here's what I have so far (I will provide all pieces that I'm using for testing):
<form action="testprocess.php" method="post">
First Name: <input type="text" name="first_name" size="20"><br /><br />
Last Name: <input type="text" name="last_name" size="20"><br /><br />
<input type="submit" value="Submit">
Main Processing Script "testprocess.php"
$first_name = urlencode($_POST['first_name']);
$last_name = urlencode($_POST['last_name']);
// Here would be all my functions that I want my script to do before sending the post variables to the other web site.
$req = "first_name=".$first_name;
$req .= "&last_name=".$last_name;
// post back to PayPal system to validate
$header .= "POST /insertacct.php 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 ('demo.mysite.com', 80, $errno, $errstr, 30);
fputs ($fp, $header . $req);
Insert Account Page
(this is the "behind-the-scenes" page that will be on a different website)
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
mysql_query(" INSERT INTO `users` (`last_name` , `first_name`) VALUES ('$last_name','$first_name')") or die(mysql_error());
The address of my script would be:
Hopefully, it doesn't matter that it is a Subdomain.