i have form to get checklist from table checkbox. inside the table, there are list of emails. i want to get that email and bomb it. somekind of marketing email. please help me to solve this php form? php to send to all emails from the checklisted table.

<form name="bomber" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" enctype="multipart/form-data">
<table width="450px">
<tr>
 <td width="50px"> </td>
 <td nowrap="nowrap">
  <span class="style40 style42">From:</span> </td>
 <td>
  <input  type="text" name="fromname" maxlength="100" size="50"> </td>
</tr>
<tr>
 <td width="50px"> </td>
 <td nowrap="nowrap">
  <span class="style40 style42">From Email:</span> </td>
 <td>
  <input  type="text" name="from" maxlength="100" size="50"> </td>
</tr>
<tr>
 <td width="50px"> </td>
 <td nowrap="nowrap">
  <span class="style40 style42">From Table:</span> </td>
 <td>
<?php
include "connect.php";
$query = "SELECT * FROM `group`";
$hasil = mysql_query($query);
$no = 1;
while ($data = mysql_fetch_array($hasil)){
  echo "<input type='checkbox' value='".$data['namagroup']."' name='mk".$no."' /> ".$data['namagroup']."<br />";
  $no++;
}
?>
 </td>
</tr>
<input type="hidden" name="jumMK" value="<?php echo $no-1; ?>" />
<tr>
 <td width="50px"> </td>
 <td nowrap="nowrap">
  <span class="style40 style42">Subject:</span> </td>
 <td>
  <input  type="text" name="subject" maxlength="200" size="50"> </td>
</tr>
<tr>
 <td width="50px"> </td>
 <td nowrap="nowrap">
  <span class="style40 style42">Message:</span> </td>
 <td>
  <textarea name="message" maxlength="1000" cols="38" rows="6"></textarea>
 </td>
</tr>
<tr>
 <td width="50px"> </td>
 <td> </td>
 <td>
  <input type="submit" name="emailbomber" value="Bomb!" onClick="document.bomber.submit()"> </td>
</tr>
</table>
</form>
Member Avatar for LastMitch

@silent lover

i have form to get checklist from table checkbox. inside the table, there are list of emails. i want to get that email and bomb it. somekind of marketing email. please help me to solve this php form? php to send to all emails from the checklisted table.

I don't know if anyone would answer this question you are asking. You are asking a Daniweb member to help you fix a code that will send SPAM emails to people.

If you have issue with your <form> read this and follow how the <form> is function:

http://www.freecontactform.com/html_form.php

this is not issue about the form but about php to send it, because my syntax did not work. here is my example :

<?php
if(isset($_REQUEST['emailbomber'])){
if (mysql_connect('localhost','username','password') && mysql_set_charset('utf8') && mysql_select_db('my_database')) {

  $errors = array();

  if (isset($_POST['subject'], $_POST['message'], $_POST['from'], $_POST['fromname'])) {

    $from = mysql_real_escape_string(htmlentities($_POST['from']));
    $fromname = mysql_real_escape_string(htmlentities($_POST['fromname']));
    $subject = mysql_real_escape_string(htmlentities($_POST['subject']));
    $message = mysql_real_escape_string(htmlentities($_POST['message']));

    if (empty($subject) || empty($message) || empty($from) || empty($fromname)) {
        $errors[] = 'All field must filled.';
    }else if(!preg_match("/^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$/i", $from)) {
        $errors[] = 'Invalid Email.';
    }

    if (strlen($from)>100 || strlen($fromname)>100 || strlen($subject)>100 || strlen($message)>1000) {
      $errors[] = 'one or more textboxs execed maximum characters.';
    }

    if (empty($errors)) {
        set_time_limit(0);
        $jumMK = $_POST['jumMK'];
        $headers = "From: $from";

        for ($i = 1; $i <= $jumMK; $i++){ 
            $eol="\n";
            $mk = $_POST['mk'.$i];
            if (!empty($mk)){
                $apa = mysql_query("select * FROM $mk");

                while ($ada = mysql_fetch_array($apa)) {
                    $to = $ada[email];
                    print_r($to);die();
                }
            }           
            $headers = "From: ".$fromname."<".$from.">".$eol;
            $headers .= "Reply-To: ".$fromname."<".$from.">".$eol;
            $headers .= "Return-Path: ".$fromname."<".$from.">".$eol;
            $headers .= "Message-ID: <".time()."-".$from.">".$eol;
            $headers .= "X-Mailer: PHP v".phpversion().$eol;
            $headers .= 'MIME-Version: 1.0'.$eol;
            $headers .= "Content-type: text/html; charset=utf-8".$eol.$eol;

            $sent = mail($to, $subject, $message, $headers);
        }
        if($sent){
            echo "<b>Email successfully send $to</b>";
        }else{
            print "<b>Something went wrong</b>"; 
        }
    } else {
      foreach($errors as $error) {
        echo '<p><strong>'.$error.'</strong></p>';
      }
    }

  }
} else {
  echo "<b>Not connected to internet.</b>";
}
}
?>

What exactly does not work? Do you get errors? If so, show them.

there are no errors but it did not work. i think php syntax that capture how many checklisted checkbox, php syntax that want to get table names (checklisted checkbox name) are the source of the fail. how to count dynamically checklisted checkbox, and get the checklisted checkbox name? so i can get the email field data from table names (checklisted checkbox name).

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.