Jump to content

Recommended Posts

So basically I have a script which the user can import a list of email addresses from their address book.  When the user imports the list of emails it shows them on the screen as a series of checkboxes and places them in an array $contacts->email_array[$key];

 

<input name="chk_email[]" type="checkbox" id="members2" value="<?php echo $contacts->email_array[$key]; ?>" checked >

 

[x] jonh@doe.com

[x] jane@doe.com

[x] brian@doe.com

 

etc....

 

The user can uncheck any addresses which they ultimately do not want to send an invitation to.

When the user unchecks the check box it is removed from the array $contacts->email_array[$key];

 

 

Once the user has checked which email address they want to send an invite to they will click a button on form2 which will direct them to the page where they actually compose the email they want to send.

 

What I need to be able to do is take this array: $contacts->email_array[$key]; and post the array to $_POST so I can access it on the createemail.php page

 

I just don't know how to go about it.

 

Chad

Link to comment
https://forums.phpfreaks.com/topic/198037-post-an-array-of-checkboxes/
Share on other sites

I think I have been staring at this too long and am forgetting the simplest thing.

 

So what I did to test this is on the same page the import code is which list the check boxes, I added another form:

<form method="post" action="index3.php">
<input type="hidden" value="<?php echo $contacts->email_array[$key]?>" name="chk_email[]">
<input type="submit" value="show checked">
</form>

 

Then in the index3.php page I added:

<?php echo $_POST['chk_email']; ?>

 

but its not printing anything to the screen.

 

 

Well I did

print_r($_POST)

and it reutrned

ArrayArray ( [chk_email] => Array ( [0] => WyReil@aol.com ) ) 1

 

the email address WyReil@aol.com is the last email address which is displayed when I did the import and printed the checkboxes  to the screen, so it appears that the entire list of email addresses is not being stored in the array.

 

Is it because it is not looping the information into $_post ?

 

If I do:

<?php 
foreach($contacts->email_array as $key=>$val)
{
echo $contacts->email_array[$key];
}
?>

 

it shows all of the addresses in the array

 

 

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.