I am creating forms where our customers can request product quotes online. When I am gathering the information on the client, there is a field to ask them how they found out about our company. There are numerous options presented as checkboxes so they could select more than one option. Each option contains further sub-options so the client can specify details.
For example:
<input type="checkbox" name="referral_type[]" value="Internet" onclick="showrfqref('internet_referral_div');" /> Internet<br />
<span id="internet_referral_div" style="display: none">
<input type="radio" name="internet_referral" value="Google" /> Google
<input type="radio" name="internet_referral" value="Yahoo" /> Yahoo!
<input type="radio" name="internet_referral" value="MSN or Windows Live" /> MSN/Windows Live
<input type="radio" name="internet_referral" value="GlobalSpec" /> GlobalSpec
<input type="radio" name="internet_referral" value="ThomasNet" /> ThomasNet
<input type="radio" name="internet_referral" value="Distributor Website" /> Distributor Website
<input type="radio" name="internet_referral" value="Other" /> Other <input type="text" name="internet_referral_other_details" class="rfq" value="<? echo $_POST['internet_referral_other_details'] ?>" maxlength="50" size="11" /> <br /><br />
</span>
When I am processing this data, it is possible for the client to select more than one referral type, each with its own set of details. I am using a foreach loop to put all of this data into one variable, called $referral_type. Here is the code I am using:
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 == '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 code seems to be passing the data through and into the $referral_type variable correctly, but my problem is that it is adding the word "Array" to the front of the data. The data it is returning looking like this:
ArrayInternet - Google
Distributor - ABC Corporation
instead of this:
Internet - Google
Distributor - ABC Corporation
I cannot figure out why it is doing this or how to prevent it from happening. Any insight you have would be much appreciated.