I'm trying to modify Jem's form so that my checkbox input(s) show up in the email that is sent.
Right now, it shows up in the email as array.
Any help would be appreciated.
I'm trying to modify Jem's form so that my checkbox input(s) show up in the email that is sent.
Right now, it shows up in the email as array.
Any help would be appreciated.
I've never used Jem's form but this is the general way to handle php form checkboxes:
Checkbox Layout (make sure you have a [] after the name)
<input type="checkbox" name="inputName[]" value="inputValue">
PHP
<?php
$checkedInputs = $_POST["inputName"];
foreach($checkedInputs as $input) {
$message .= $input;
}
?>
Exactly, I know how to do it normally, but not so sure how to implement the processing with Jem's form. What I've done isn't working (similar to what you've done above) and I assumed I was doing something wrong.
Jem's form processes the form inputs in the following way to create the email
foreach ($_POST as $key => $val) {
$message .= ucwords($key) . ": " . clean($val) . "\r\n";
}
I'm not sure based on that how to process the checkbox input.
ok, so it'd be a two dimensional array so you'd have to check if is_array($val) and if is_array($val) do a foreach loop on it.
foreach ($_POST as $key => $val) {
if(is_array($val)) {
$message .= ucwords($key) . ": ";
foreach($val as $v) {
$message .= clean($v)", ";
}
$message .= "\r\n";
} else {
$message .= ucwords($key) . ": " . clean($val) . "\r\n";
}
}
THANK YOU! I had gotten it working but it certainly wasn't using the is_array function because I tried and failed with that. I was using if statements (e.g. if $key == "classes") and knew I was not doing it the best way.
I appreciate your help, Rose and your quick reply tonight!
No problem, glad to be helpful. Sorry the is_array thing didn't work for you though! Makes me want to play around with it...
Well, it would have worked if I had done it right lol. :)
Sorry, thought I'd fixed that one ages ago - oh deary me :x
You must log in to post.