I am unable to get the array values after clicking submit in php

I have an html table that displays certain rows, and each row consists of an email id. I kept a check=box at the end of each row. So user can check any of the check-boxes and click ‘send email’ button. On submitting an email has to pop up with all the selected emails ids in the ‘TO’ field.

As of now, I am trying to get the values into an array, and trying to display them. This is for my reference. After that I want to add the mail sending feature.

But my problem is, after checking some check-boxes and clicking submit, my selected emails are not being displayed. It is directly displaying the content in ‘else’, saying ‘no emails are selected’. Thanks in advance.

My code( part of) in html table display page is

if($result222->num_rows > 0){
//echo '<table cellpadding="0" cellspacing="0" border="1" class="db-table">';

echo '<table width="100%" id="tblData1" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" border="1" class="tablesorter"   boarder-collapse ="collapse">';

echo '<thead><tr bgcolor = "#58B0EB"><th>STUDENT_NAME</th><th>ID_NUMBER</th><th>PHONE_NUMBER</th><th>BRANCH</th><th>YEAR</th><th>CONTACT_PERSON</th><th>EMAIL_ID</th><th>NOTES</th><th><form action="sendemail.php" method="POST"><br/><input id="chk" type="checkbox" name="sel_desel"> </th></tr></thead>';
while($rowz222 = mysqli_fetch_assoc($result222)){

echo "<tr>";

foreach($rowz222 as $key=>$value){

if($key=='ci_email') {

echo '<td><a href="mailto:'.$value.'">'.$value.'</a></td>';


echo '<td>',$value,'</td>';


echo '';

echo '<td><input id="checkbox" type="checkbox"  name="checklist[]" value=" ' .$email[$i]. '">';
echo $email[$i];

echo '</td>';

echo '</tr>';

echo '<input id="send" type="submit" name="sendemail" value="SEND_EMAIL">';
echo '</form>';

My code in ‘sendemail.php’ is




        echo "The following email addresses have been selected:<br />"; 

            foreach($arr as $selected) 
                echo $selected; 



    else {
    echo 'no emails selected';

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s