Jump to content

Multiple Checkbox and mail ()


farnoise

Recommended Posts

Hi,

I'm a newbie in PHP and I have a form that has about 130 check boxes (I know its a lot) these 130 boxes has been splited in different groups and each group has 20 boxes, SO some values are same in different groups. so what I want to do is use the same name for all check boxes but different values, I tries checkbox[] function but all it gives me in my message line is "Array" for ex. if I check 10 different boxes it should give the value names for 10 different boxes but all i see is "Array".

 

PS: I dont want to echo my output, it has to be sent to recieptent via mail() function I got that all

 

here is my code:

 

check box name is = chkexpert[]  for all check boxes

 

HTML (only 3 of them is here)

_____

 

          <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Voice mail"  />

            Voice mail <br />

            <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Long Dst. Code"  />

            Long Dst. Code <br />

            <input name="chkexpert[]" type="checkbox" id="chkexpert" value="Laptop"  />

            Laptop <br />

.......

_______

 

PHP CODE

 

 

$chkexpert = addslashes($_POST['chkexpert']);

 

>>>

in my message line I have;

 

$message = " Hi, Your list is $chkexpert "

 

 

So when visitor choose 4 of that check boxes I'm recieving email says : Hi, Your list is Array

 

Thanks GUYS PLEASE HELP  :'( :'( :'(

Link to comment
Share on other sites

By naming the checkboxes with [] at the end you are turning them into arrays. When you echo an array you simply get the word 'Array' as you have already found. You will need to convert it into a string that contains all the values in the array. There's lots of ways of doing it, but here's a quick example of one way.

 

function concat($a, $b) {
    if($a) {
       return $a . ", " . $b;
    } else {
        return $b;
    }
}
$input = array(1, 2, 3, 4, 5);
$output = array_reduce($input, "concat");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.