Need to Post Form Data via HTTP....

Hey all,

I have a php based form that works well - and emails the results of the form via email (managed via a processor.php file). I want to modify the processor.php to post the data to a URL as this example:

########
firstName=John&lastName=Doe&spouseFirstName=Jane&spouseLastName=Doe&homePhone=09808080&workPhone=09809809&cellPhone=098098&[email protected]&loanAmount=097798798&loanType=Refinance&propertyType=Single+Family&propertyValue=75000&creditScore=Excellent&postedDate=&URL=http://www.domainname.com/index.xxx
#########

What do I need to change in the processor.php file to post to a URL vs Email as it is today? Here’s the contents of processor.php file below…willing to throw some money via paypal to get this going…

PROCESSOR.PHP

<?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); mail("[email protected]","phpFormGenerator - Form submission","Form data: First Name: " . $_POST['field_1'] . " Last Name: " . $_POST['field_2'] . " City: " . $_POST['field_3'] . " State: " . $_POST['field_4'] . " Zip: " . $_POST['field_5'] . " Email: " . $_POST['field_6'] . " Phone: " . $_POST['field_7'] . " Marital Status: " . $_POST['field_8'] . " Homeowner: " . $_POST['field_9'] . " Driver 1: Name: " . $_POST['field_10'] . " Driver 1: Sex: " . $_POST['field_11'] . " Driver 1: Years US Licensing: " . $_POST['field_12'] . " Driver 1: Birthdate: " . $_POST['field_13'] . " Driver 2: Name: " . $_POST['field_14'] . " Driver 2: Birthdate: " . $_POST['field_15'] . " Driver 2: Sex: " . $_POST['field_16'] . " Driver 2: Years US Licensing: " . $_POST['field_17'] . " Vehicle 1: Year: " . $_POST['field_18'] . " Vehicle 1: Make & Model: " . $_POST['field_19'] . " Vehicle 1: ID#: " . $_POST['field_20'] . " Vehicle 1: Annual Mileage: " . $_POST['field_21'] . " Vehicle 1: Used car?: " . $_POST['field_22'] . " Vehicle 1: Used for Business?: " . $_POST['field_23'] . " Vehicle 2: Year: " . $_POST['field_24'] . " Vehicle 2: Make & Model: " . $_POST['field_25'] . " Vehicle 2: ID#: " . $_POST['field_26'] . " Vehicle 2: Annual Milage: " . $_POST['field_27'] . " Vehicle 2: Used Car?: " . $_POST['field_28'] . " Vehicle 2: Used for Business?: " . $_POST['field_29'] . " Vehicle 1: Coverage: " . $_POST['field_30'] . " Vehicle 1: Comprehensive Deductible: " . $_POST['field_31'] . " Vehicle 1: Collision Deductible: " . $_POST['field_32'] . " Vehicle 1: Uninsured Motorists: " . $_POST['field_33'] . " Vehicle 1: Rental Car: " . $_POST['field_34'] . " Vehicle 1: Medical and or PIP: " . $_POST['field_35'] . " Vehicle 2: Liability Limits: " . $_POST['field_36'] . " Vehicle 2: Comprehensive Deductible: " . $_POST['field_37'] . " Vehicle 2: Collision Deductible: " . $_POST['field_38'] . " Vehicle 2: Uninsured Motorists: " . $_POST['field_39'] . " Vehicle 2: Rental Car: " . $_POST['field_40'] . " Vehicle 2: Medical and or PIP: " . $_POST['field_41'] . " powered by phpFormGenerator. "); include("confirm.html"); ?>

PROCESSOR.PHP

Here is an example how you can post 2 fields, you can guess how to add all your other fields :slight_smile:
Note: replace yourdomain.com, yourdir and yourscript.php in the code below with your values.

[php]<?php

$url = ‘www.yourdomain.com’;

$fp = fsockopen($url, 80, $errno, $errstr, 30);
if (!$fp) {
echo ‘Could not open connection.’;
}
else {

$vars = “firstName=”.$_POST[‘field_1’]."&lastName=".$_POST[‘field_2’];
$contentlength = strlen($vars);

$out = “POST /yourdir/yourscript.php HTTP/1.0\r\n”;
$out .= “Host: “.$url.”\r\n”;
$out .= “Connection: Keep-Alive\r\n”;
$out .= “Content-type: application/x-www-form-urlencoded\r\n”;
$out .= “Content-length: $contentlength\r\n\r\n”;
$out .= $vars;

fwrite($fp, $out);
while (!feof($fp)) {
$theOutput .= fgets($fp, 128);
}
fclose($fp);

// use the value below to see response of script where you posted data
//echo $theOutput;
}

?>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service