php form optional fields problem

I am trying to write code that will let a user enter information in an optional content, if the user uses them then that is then added to the e-mail that is sent back to me. Every thing does work other then getting the while loop to bring back that optional data if any.

can anyone point out what i have wrong?

[php] elseif(isset($_POST[‘postedRequest’])) {
$subject = $_POST[‘formType’];
$message = "Broker Name: " . $_POST[‘brokerName’] . “\n” . "Agency Name: " . $_POST[‘agencyName’] . “\n” . "Broker Address: " . $_POST[‘brokerAddress’] . " ". $_POST[‘brokerCity’] . " " . $_POST[‘brokerState’] . " " . $_POST[‘brokerZip’]. “\n” . "Broker Phone #: " . $_POST[‘brokerPhone’]. “\n” . “\n”. “Broker Fax #: " .” ". $_POST[‘brokerFax’] . “\n” . “Broker License #: " . $_POST[‘brokerLicenseNumber’] . “\n” . “Broker Email: " . $_POST[‘brokerEmail’] .”\n” . "Company Name: " . $_POST[‘companyName’] . “\n” . "Business Type: " . $_POST[‘businessType’]. “\n” . "Company Contact Name: " . $_POST[‘companyContactName’] . “\n” . "Company Address: " . $_POST[‘companyAddress’]. " ". $_POST[‘companyCity’] . " " . $_POST[‘companyState’] . " " . $_POST[‘companyZip’] . “\n” . " " . "Company Phone: " . $_POST[‘companyPhone’] . “\n” . "Company Email: " . $_POST[‘companyEmail’] . “\n” . "Receive Quote By: " . $_POST[‘receiveQuoteBy’] . “\n” . "Comments: " . $_POST[‘comments’] . “\n” . “\n”. "Current Carrier: " . $_POST[‘currentCarrier’] . “\n” . "Current Rates: " . $_POST[‘currentRates’] . “\n” . "Why Changing: " . $_POST[‘whyChanging’] . “\n” . "Percent Employees: " . $_POST[‘percentEmployees’] . “\n” . "Percent Dependants: " . $_POST[‘percentDependants’] . “\n” . "Desired Plan Type: " . $_POST[‘desiredPlanType’] . “\n” . "Date Of Coverag: " . $_POST[‘dateOfCoverag’] . “\n” . "Eligible Emloyees: " . $_POST[‘eligibleEmloyees’] . “\n” . "Eligible Dependants: " . $_POST[‘eligibleDependants’] . “\n” . "Desired Plan Type: " . $_POST[‘desiredPlanType’];

$i = 0;
while ($i <= 14) {
	if (isset($_POST['employee'.$i.'Name'])) {
		$message = "employee".$i."Name: " . $_POST['employee'.$i.'Name'] . "\n" . "employee".$i."DOB: " . $_POST['employee'.$i.'DOB'] . "\n" . "employee".$i."Gender: " . $_POST['employee'.$i.'Gender'] . "\n" . "employee".$i."DOB: " . $_POST['employee'.$i.'DOB'] . "\n" . "employee".$i."Status: " . $_POST['employee'.$i.'Status'] . "\n" . "employee".$i."DependantChildren: " . $_POST['employee'.$i.'DependantChildren'] . "\n" . "employee".$i."Status: " . $_POST['employee'.$i.'Status'] . "\n" . "employee". $i ."Status: " . $_POST['employee'.$i.'Status'];
	
	$i++;
	};
};

$from = $_POST['employerContact'] . " " . $_POST['employerContactEmail'];
$headers = "From: " . $from;
$to = "[email protected]";

};
$sent = mail($to,$subject,$message,$headers);[/php]

I have updated my code from the previews post, i changed the while loop to a for loop, still having problems.

[php]<?php
if(isset($_POST[‘postedChange’])) {
$subject = $_POST[‘formType’];
$message = "Employer: " . $_POST[‘employer’] . “\n” . "Employer Contact: " . $_POST[‘employerContact’] . “\n” . "Employer Contact Phone: " . $_POST[‘employerContactPhone’] . “\n” . "Employer Contact Email: " . $_POST[‘employerContactEmail’]. “\n” . “\n”. “Member Name: " . $_POST[‘memberFirstName’] .” “. $_POST[‘memberMiddleName’] .” ". $_POST[‘memberLastName’] . “\n” . “Date of Birth: " . $_POST[‘memberDOB’] . “\n” . “Gender: " . $_POST[‘memberGender’] .”\n” . "Email Address: " . $_POST[‘memberEmail’] . “\n” . "Home Address: " . $_POST[‘homeAddress’] . " ". $_POST[‘memberHomeCity’] . " " . $_POST[‘memberHomeState’] . " " . $_POST[‘memberHomeZip’] . “\n” . "Home Phone Number: " . $_POST[‘homePhone’] . “\n” . "Preferred Language: " . $_POST[‘language’] . “\n” . "Plan Change: " . $_POST[‘desiredPlanType’];
$from = $_POST[‘employerContact’] . " " . $_POST[‘employerContactEmail’];
$headers = “From: " . $from;
$to = "[email protected],[email protected]”;

} elseif(isset($_POST[‘postedTerminate’])) {
$subject = $_POST[‘formType’];
$message = "Employer: " . $_POST[‘employer’] . “\n” . "Employer Contact: " . $_POST[‘employerContact’] . “\n” . "Employer Contact Phone: " . $_POST[‘employerContactPhone’] . “\n” . "Employer Contact Email: " . $_POST[‘employerContactEmail’]. “\n” . “\n”. “Member Name: " .” “. $_POST[‘memberFirstName’] .” “. $_POST[‘memberMiddleName’] .” ". $_POST[‘memberLastName’] . “\n” . “Date of Birth: " . $_POST[‘memberDOB’] . “\n” . “Gender: " . $_POST[‘memberGender’] .”\n” . "Email Address: " . $_POST[‘memberEmail’] . “\n” . "Home Address: " . $_POST[‘memberHomeAddress’] . " ". $_POST[‘memberHomeCity’] . " " . $_POST[‘memberHomeState’] . " " . $_POST[‘memberHomeZip’] . “\n” . "Home Phone Number: " . $_POST[‘homePhone’] . “\n” . "Preferred Language: " . $_POST[‘language’] . “\n” . "Termination Effective Date: " . $_POST[‘terminationEffectiveDate’];
$from = $_POST[‘employerContact’] . " " . $_POST[‘employerContactEmail’];
$headers = “From: " . $from;
$to = "[email protected]”;

} elseif(isset($_POST[‘postedRequest’])) {
$subject = $_POST[‘formType’];
$message = "Broker Name: " . $_POST[‘brokerName’] . “\n” . "Agency Name: " . $_POST[‘agencyName’] . “\n” . "Broker Address: " . $_POST[‘brokerAddress’] . " ". $_POST[‘brokerCity’] . " " . $_POST[‘brokerState’] . " " . $_POST[‘brokerZip’]. “\n” . "Broker Phone #: " . $_POST[‘brokerPhone’]. “\n” . “\n”. “Broker Fax #: " .” ". $_POST[‘brokerFax’] . “\n” . “Broker License #: " . $_POST[‘brokerLicenseNumber’] . “\n” . “Broker Email: " . $_POST[‘brokerEmail’] .”\n” . "Company Name: " . $_POST[‘companyName’] . “\n” . "Business Type: " . $_POST[‘businessType’]. “\n” . "Company Contact Name: " . $_POST[‘companyContactName’] . “\n” . "Company Address: " . $_POST[‘companyAddress’]. " ". $_POST[‘companyCity’] . " " . $_POST[‘companyState’] . " " . $_POST[‘companyZip’] . “\n” . " " . "Company Phone: " . $_POST[‘companyPhone’] . “\n” . "Company Email: " . $_POST[‘companyEmail’] . “\n” . "Receive Quote By: " . $_POST[‘receiveQuoteBy’] . “\n” . "Comments: " . $_POST[‘comments’] . “\n” . “\n”. "Current Carrier: " . $_POST[‘currentCarrier’] . “\n” . "Current Rates: " . $_POST[‘currentRates’] . “\n” . "Why Changing: " . $_POST[‘whyChanging’] . “\n” . "Percent Employees: " . $_POST[‘percentEmployees’] . “\n” . "Percent Dependants: " . $_POST[‘percentDependants’] . “\n” . "Desired Plan Type: " . $_POST[‘desiredPlanType’] . “\n” . "Date Of Coverag: " . $_POST[‘dateOfCoverag’] . “\n” . "Eligible Emloyees: " . $_POST[‘eligibleEmloyees’] . “\n” . "Eligible Dependants: " . $_POST[‘eligibleDependants’] . “\n” . "Desired Plan Type: " . $_POST[‘desiredPlanType’];

for ($i=0; $i<=14; $i++) {
	if (isset($_POST['employee'.$i.'Name'])) {
		$message = "employee".$i."Name: " . $_POST['employee'.$i.'Name'] . "\n" . "employee".$i."DOB: " . $_POST['employee'.$i.'DOB'] . "\n" . "employee".$i."Gender: " . $_POST['employee'.$i.'Gender'] . "\n" . "employee".$i."DOB: " . $_POST['employee'.$i.'DOB'] . "\n" . "employee".$i."Status: " . $_POST['employee'.$i.'Status'] . "\n" . "employee".$i."DependantChildren: " . $_POST['employee'.$i.'DependantChildren'] . "\n" . "employee".$i."Status: " . $_POST['employee'.$i.'Status'] . "\n" . "employee". $i ."Status: " . $_POST['employee'.$i.'Status'];
	
	};
};

};

$from = $_POST['employerContact'] . " " . $_POST['employerContactEmail'];
$headers = "From: " . $from;
$to = "[email protected]";

$sent = mail($to,$subject,$message,$headers);
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service