I got 1 form that contain a table that can be editable . In that table i added 1 column for checkbox . The checkbox is use to send a notification email based on the checked box . I want to create a button that connect to the page which contain the email form etc . Here what i got so far .. This is the table coding .

<form name="form2" method="post" action="simpan_maklumbalas.php" class="search_form">
    <input type="hidden" name="idk" value="<?php echo $_REQUEST['idk']; ?>" />
    <strong>Senarai Calon Dihantar</strong>
    <table width="850" border="1">
      <tr align="center">
        <th width="50" scope="col">&nbsp;</th>
        <th width="80" scope="col">Tarikh Temuduga</th>
        <th width="120" scope="col">Nama</th>
        <th width="98" scope="col">No Tel</th>
        <th width="79" scope="col">Keputusan</th>
        <th width="80" scope="col">Tarikh Penempatan</th>
        <th width="144" scope="col">Sebab Ditolak</th>
        <th width="100" scope="col"><input type="checkbox" onChange="checkAll()" />Semua ke?<br/></th>
      </tr>
    <?php 
    $disable = '';
    $i = 0;
    $d = 0;


$sql = "SELECT a.*, b.nama, b.tel_bimbit FROM kekosongan_jobseeker a 
INNER JOIN jobseeker b ON a.nokp_jobseeker = b.no_kp 
WHERE id_kekosongan = '".addslashes($_REQUEST['idk'])."'";
$res_list = mysql_query($sql);
while($row_list = mysql_fetch_array($res_list)){
    $i++;
?>  
  <tr id="edit_<?php echo $i; ?>" <?php echo $color; ?>>
    <td id="notify_<?php echo $i; ?>" align="center">
        <a onclick="createField(<?php echo $i; ?>)" style="cursor:pointer">Edit</a>
    </td>
    <td align="center"><div id="dt_ctemuduga_<?php echo $i; ?>"><?php if($row_list['dt_temuduga'] != '0000-00-00'){ echo dt2display($row_list['dt_temuduga']); }else{ echo "-"; } ?></div></td>
    <td align="left"><?php echo displayNama(ucwords(stripslashes($row_list['nama'])), $row_list['nokp_jobseeker']); ?>
        <input type="hidden" name="idkj_<?php echo $i; ?>" id="idkj_<?php echo $i; ?>" value="<?php echo $row_list['id']; ?>" /></td>
    <td align="center"><?php echo ucwords(stripslashes($row_list['tel_bimbit'])); ?></td>
    <td align="center"><div id="keputusan_<?php echo $i; ?>"><?php if($row_list['keputusan'] != ''){ echo ucwords($row_list['keputusan']); }else{ echo 'Tiada'; } ?></div></td>
    <td align="center"><div id="dt_ctempat_<?php echo $i; ?>"><?php if($row_list['dt_penempatan'] != '0000-00-00'){ echo dt2display($row_list['dt_penempatan']); }else{ echo '-'; } ?></div></td>
    <td><div id="tolak_<?php echo $i; ?>"><?php if($row_list['sebab_tolak'] != ''){ echo stripslashes($row_list['sebab_tolak']); }else{ echo '&nbsp;&nbsp;-'; } ?></div></td>
    <td align="center"><input type="checkbox" name="email_<?php echo $i; ?>" />
    <input type="hidden" name="total_email" id="total_email" value="<?php echo $row_list['email']; ?>" /></td>
</tr>
<?php
}
if($i == 0){
?>
<tr><td colspan="7">Tiada data.</td></tr>
<?php
    $disable = 'disabled="disabled"';
}
?>
</table>
</form><?php
if($row['status_tawaran'] == 'buka'){
?> 
<br>

Button to send the email and other button .

<table width="600" border="0" cellspacing="2" cellpadding="0">
  <tr align="center">
    <td width="300" align="right">Kembali&nbsp;<a href="carian_pekerja.php?idk=<?php echo $_REQUEST['idk']; ?>"><img src="images/back_24.png" width="24" height="24" border="0" align="absbottom"></a></td>
    <td width="300" align="left">Tutup&nbsp;<a href="tutup_iklan.php?idk=<?php echo $row['id']; ?>&from=maklumbalas"><img src="images/lock_24.png" width="24" height="24" border="0" align="absbottom"></a>
    <td width="300" align="left">Send Email&nbsp;<a href="send_email.php"><img src="images/email.png" width="24" height="24" border="0" align="absbottom"></a></td>
  </tr>
</table>

send_email.php

<?php
session_start();

require_once "inc/db.php";
require_once "inc/tarikh.php";


// subject
$subject = 'Maklumat Majikan dan Tarikh Temuduga';

// message
$message = '
<html>
<body>
 // message
</body>
</html>
';


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: JobsMalaysia Centre <jmciskandar_m@mohr.gov.my>' . "\r\n";
$headers .= 'Cc: email@example.com' . "\r\n";
$headers .= 'Bcc: email2@example.com' . "\r\n";

if(isset($_POST['total_email']) && is_array($_POST['total_email'])){
    foreach($_POST['total_email'] as $to){
    mail($to, $subject, $message, $headers);
    }
}
else{
 echo "No email addresses to send to!";
}

?>

The problem is when i clicked the button . It print 'No email addresses to send to!' . Please help me out

Recommended Answers

All 3 Replies

your sendbutten is just a link to send_email.php

to actualy send your form :<input type="submit" value="send eamail"> before the </form>
also change <form name="form2" method="post" action="send_email.php" class="search_form">
or use javascript

thanks for the reply pzuurveen . But if i change the

<form name="form2" method="post" action="send_email.php" class="search_form"> 

can the table be editable ? and could you show the structure of the javascript ? i'm suck at javascript ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.