I am building a form that will allow my company's customers to request product quotes online. As part of the "Client Information" we are asking them to tell us how they learned about our company. There are a number of options, and the user can select more than one. For each option, there are a number of sub-options where they can specify further details.
When processing this form data, I am treating this data as an array using a foreach loop. My problem is that when the output comes, it is printing the word "Array" in front of the data.
The code I am using to process the data and create the variables to insert into the database is as follows:
foreach($_POST['referral_type'] as $referral_type_value) {
if ($referral_type_value == 'Internet') { $referral_details = $_POST['internet_referral'];
if ($referral_details == 'Other') { $referral_details .= ' - '.$_POST['internet_referral_other_details']; }
}
if ($referral_type_value == 'Distributor') { $referral_details = $_POST['distributor_details']; }
if ($referral_type_value == 'CCI Thermal Employee') { $referral_details = $_POST['employee_details']; }
if ($referral_type_value == 'Industry Colleague') { $referral_details = $_POST['industrycolleague_details']; }
if ($referral_type_value == 'Trade Show') { $referral_details = $_POST['tradeshow_details']; }
if ($referral_type_value == 'Print Advertising') { $referral_details = $_POST['printad_details']; }
if ($referral_type_value == 'Other') { $referral_details = $_POST['other_details']; }
$referral_type .= $referral_type_value.' - '.$referral_details.'\n';
}
The result after inserting the $referral_type variable output into my database appears as follows:
ArrayInternet - Google
Distributor - Westburne
I intend it to appear as follows:
Internet - Google
Distributor - Westburne
Anybody have any insight into why this is happening or how to fix it?