cbarlow
05-14-2008, 06:26 PM
i am working on an order form for a friend and need to know where to enter an array in the php code. here is the php...
foreach ($_POST as $key => $value) {
$key = clear_user_input($key);
$value = clear_user_input($value);
if ($key=='extras') {
if (is_array($_POST['magnetic thoughts']) ){
$body .= "$key: ";
$counter =1;
foreach ($_POST['magnetic thoughts'] as $value) {
//Add comma and space until last element
if (sizeof($_POST['magnetic thoughts']) == $counter) {
$body .= "$value\n";
break;}
else {
$body .= "$value, ";
$counter += 1;
}
}
} else {
$body .= "$key: $value\n";
}
} else {
$body .= "$key: $value\n";
}
}
I have my html like this.....
<p class="legend">magnetic thoughts @ 3.95 each</p>
<fieldset id="choices">
<p id="magnetic thoughts">
<input type="checkbox" name="magnetic thoughts[]" value="ma01" />ma01
<input type="checkbox" name="magnetic thoughts[]" value="ma02" />ma02
</p>
</fieldset>
there are many other items but noone needs to see all of that.
any help is appreciated.
foreach ($_POST as $key => $value) {
$key = clear_user_input($key);
$value = clear_user_input($value);
if ($key=='extras') {
if (is_array($_POST['magnetic thoughts']) ){
$body .= "$key: ";
$counter =1;
foreach ($_POST['magnetic thoughts'] as $value) {
//Add comma and space until last element
if (sizeof($_POST['magnetic thoughts']) == $counter) {
$body .= "$value\n";
break;}
else {
$body .= "$value, ";
$counter += 1;
}
}
} else {
$body .= "$key: $value\n";
}
} else {
$body .= "$key: $value\n";
}
}
I have my html like this.....
<p class="legend">magnetic thoughts @ 3.95 each</p>
<fieldset id="choices">
<p id="magnetic thoughts">
<input type="checkbox" name="magnetic thoughts[]" value="ma01" />ma01
<input type="checkbox" name="magnetic thoughts[]" value="ma02" />ma02
</p>
</fieldset>
there are many other items but noone needs to see all of that.
any help is appreciated.