aeboi80 Posted April 8, 2010 Share Posted April 8, 2010 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 Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 8, 2010 Share Posted April 8, 2010 you are 90% there. That line is fine. When you post that your array would be $_POST['chk_email'] any that are checked would be there. Quote Link to comment Share on other sites More sharing options...
aeboi80 Posted April 8, 2010 Author Share Posted April 8, 2010 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. Quote Link to comment Share on other sites More sharing options...
the182guy Posted April 8, 2010 Share Posted April 8, 2010 You should print out the entire post so you can see exactly what has been posted and what the keys and values are. To do that use: print_r($_POST); Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 8, 2010 Share Posted April 8, 2010 plus even if it's only one value $_POST['chk_email'] is an array. So you should have done print_r($_POST['chk_email']); but doing the whole post variable is better, gives you an idea of what is actually being passed. Quote Link to comment Share on other sites More sharing options...
aeboi80 Posted April 8, 2010 Author Share Posted April 8, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.