Jump to content

help on my HTML email options


pixeltrace

Recommended Posts

guys,

 

i need help, its been several days already and i havent fixed thoroughly my problem on my HTML email sending

below is my page

http://www.jobhirings.com/admean/email/blast.php

 

this blasting page is working for individual email sending only.

but if i select entire list or specialization.

its not working and i intentionally print the POST so i can see if its picking up

the emails on this two options.

 

my friend told me to just loop the dbemail variabbles for entire list and specialization option but i dont know how

and where to place it.

 

hope you could help me with this.

 

below is my codes for the blast.php page

<?php
session_start();
ob_start();
include '../db_connect.php';
include_once("FileUpload.php");
include_once("Functions.php");
$dir = "D:/xampp/htdocs/test/data/";
$dir = "/home/museikne/www/misc/";
$active = false;
$error = "";
$text = "List:
";

$subject = stripslashes($_POST['SUBJECT']);
$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";
$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";
// Clear All
if(isset($_POST['CANCEL'])){
   unset($_SESSION['LIST']);
   unset($_SESSION['URL']);
}
// Clear URL Content
if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);
if(isset($_POST['AMEND'])){
   $_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);
}
// Get URL Content
if(isset($_POST['GETURL'])){
   if(trim($_POST['URL']) == ""){
      $error = "Please fill in the url";
   }else{
      $file = fopen($_POST['URL'], "r") or exit("Invalid URL!");
      //Output a line of the file until the end is reached
      while(!feof($file))
        {
         $body .= fgets($file);
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
        }
      fclose($file);
      //$body = str_replace("%name%", "chuyang", $body);
      $_SESSION['URL'] = $body;
   }
}

// Import name list
if(isset($_POST['IMPORT'])){
   $validFile = array("txt"); // valid file formats
   $file = $_FILES['FILE'];
   if($file['name'] != ''){
      unset($_SESSION['LIST']);
      $fu = new FileUpload($file, $dir);
      $fu->CheckFileFormat($validFile);
      $fu->UploadFile();
      $file = fopen($dir."list.txt", "r") or exit("Unable to open file!");
      //Output a line of the file until the end is reached
      while(!feof($file))
      {
         $email = fgets($file);
         $email = explode(",",$email);
         $_SESSION['LIST'][] = $email;
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
      }
      fclose($file);
   }else{
      unset($_SESSION['LIST']);
      $error = "Please locate the file";
   }
   //header("Location:$PHP_SELF");
}
if(isset($_SESSION['LIST'])){
   $i = 1;
   foreach($_SESSION['LIST'] as $key=>$val){
      $name = $val[0];
      $email = $val[1];
      $text.= "$i ."."$name - $email
";
      $i++;
   }
   print $text;
}

if(isset($_POST['SEND'])){
print_r($_POST);
if ($_POST['to'] == "all"){
	$query = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'") or die(mysql_error());
	$row = mysql_fetch_array( $query );
	$dbemail = $row['email'];

}
if ($_POST['to'] == "notall"){
	$specialization = $_POST['specialization'];
	$query = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'") or die(mysql_error());
	$row = mysql_fetch_array( $query );
	$dbemail = $row['email'];

}
if ($_POST['to'] == "peremail"){
$dbemail = $_POST['email'];
}
//print_r($dbemail);

// After getting list of $dbemail, then send accordingly:
// : $mail->SendHTML($dbemail,$subject,$new_msg);
   if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";
   if($error == ""){
      require_once("Mail.php");
      $mail = new Mail();
      $mail->SetHeader($header);
  $original_msg = $_SESSION['URL'];
  $mail->SendHTML($dbemail,$subject,$original_msg);
     if(isset($_SESSION['LIST'])){
         
         foreach($_SESSION['LIST'] as $key=>$val){
            $new_msg = str_replace("%name%", $val[0], $original_msg);
		// See above
            $mail->SendHTML($val[1],$subject,$new_msg);
         }
         session_destroy();
         header("Location:$PHP_SELF");
      }
   }
}
if($active){
   $file = fopen("html.txt", "r") or exit("Unable to open file!");
   //Output a line of the file until the end is reached
   while(!feof($file))
     {
      $email .= fgets($file);
      
      //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
     }
   fclose($file);
   $email = str_replace("\"", "\\\"", $email);
   print $email;
   print "END";
}
//$bodytag = str_replace("'", "\'", $body);
echo $error;
?>
<script language="JavaScript">
function event_action(spl_value)
{
   if(spl_value=="peremail")
   {
      test.style.visibility="visible";
      test2.style.visibility='hidden';
   }
   else if(spl_value=="notall")
   {
      test2.style.visibility="visible";
      test.style.visibility='hidden';
   }
   else
   {
      test.style.visibility='hidden';
      test2.style.visibility='hidden';
   }
}
</script>
<link href="../../css.css" rel="stylesheet" type="text/css" />
<link href="../css.css" rel="stylesheet" type="text/css" />

<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
        <td width="214" valign="top"><form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <table  border="0" cellspacing="0" cellpadding="3">
            <tr>
              <td colspan="2" valign="top" nowrap="nowrap" class="text3"><img src="../images/spacer.gif" width="469" height="7" /></td>
              </tr>
            <tr>
              <td width="83" align="left" nowrap="nowrap" class="text3">Subject:</td>
              <td width="381" align="left"><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"  class="textfield1"></td>
            </tr>
            <tr>
              <td align="left" class="text3">From:</td>
              <td align="left"><input name="FROM" type="text" id="FROM" value="<?php print $header;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td align="left" class="text3">Sent to :</td>
              <td align="left"><span class="text7">
                <select name="to" class="textfield1" onchange="event_action(this.value);">
                  <option selected="selected" value="">--Email Option--</option>
                  <option value="all">Entire list</option>
                  <option value="notall">Specialization</option>
                  <option value="peremail">Individual Email</option>
                </select>
                <!--<input name="select" type="submit" id="select" value="select" />//-->
              </span></td>
            </tr>
            <!-- condition for the select menu -->
            <tr id="test2" style="visibility:hidden">
              <td align="left" class="text3">Specialization:</td>
              <td align="left"><select name="specialization" class="textfield1">
                  <option value="" selected="selected">-- Select Here --</option>
                  <?
         $uSql = "SELECT specialization FROM specialization";
         $uResult = mysql_query($uSql, $connection);
         if(!$uResult){
         echo 'no data found';
         }else{
         while($uRow = mysql_fetch_array($uResult)){
            ?>
                  <option value="<?= $uRow[specialization]?>">
                    <?= $uRow[specialization]?>
                    </option>
                  <?   }    } ?>
                </select>              </td>
            </tr>
            <tr id="test" style="visibility:hidden">
              <td align="left" class="text3">Email:</td>
              <td align="left"><input type="text" name="email" value="" class="textfield1" /></td>
            </tr>
            <!-- end -->
            <tr>
              <td align="left" class="text3">URL:</td>
              <td align="left"><input name="URL" type="text" id="URL" value="<?php print $url;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><?php if(isset($_SESSION['URL'])){?>
                  <textarea name="URLPREVIEW" cols="60" rows="10" id="URLPREVIEW" class="textfield1"><?php print $_SESSION['URL']?></textarea>
                  <br />
                  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear" />
                  <input name="AMEND" type="submit" id="AMEND" value="Change" />
                  <?php }?>
                  <input name="GETURL" type="submit" id="GETURL" value="Get URL" />              </td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><input name="SEND" type="submit" id="SEND" value="Send" />
                  <input name="CANCEL" type="submit" id="CANCEL" value="Cancel" /></td>
            </tr>
            <tr>
              <td colspan="2"><span class="text3"><img src="../images/spacer.gif" width="469" height="7" /></span></td>
              </tr>
          </table>
        </form></td>
        <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
    </table></td>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
        <td><table width="216" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
              <td width="214" valign="top"> </td>
              <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
        </table></td>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php ob_end_flush();?>

 

 

thanks!

Link to comment
Share on other sites

Hi,

 

I tried it again and its working

but i got another problem, from the entire list and specialization condition

its only sending to the last email address that is registered or save on my database.

 

how or whatelse should i add in my code so that it will send to all

the email addresses that is in my database considering the set conditions

in my query?

 

need help please

 

below is my current code

<?php
session_start();
ob_start();
include '../db_connect.php';
include_once("FileUpload.php");
include_once("Functions.php");
$dir = "D:/xampp/htdocs/test/data/";
$dir = "/home/museikne/www/misc/";
$active = false;
$error = "";
$text = "List:
";

$subject = stripslashes($_POST['SUBJECT']);
$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";
$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";
// Clear All
if(isset($_POST['CANCEL'])){
   unset($_SESSION['LIST']);
   unset($_SESSION['URL']);
}
// Clear URL Content
if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);
if(isset($_POST['AMEND'])){
   $_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);
}
// Get URL Content
if(isset($_POST['GETURL'])){
   if(trim($_POST['URL']) == ""){
      $error = "Please fill in the url";
   }else{
      $file = fopen($_POST['URL'], "r") or exit("Invalid URL!");
      //Output a line of the file until the end is reached
      while(!feof($file))
        {
         $body .= fgets($file);
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
        }
      fclose($file);
      //$body = str_replace("%name%", "chuyang", $body);
      $_SESSION['URL'] = $body;
   }
}

// Import name list
if(isset($_POST['IMPORT'])){
   $validFile = array("txt"); // valid file formats
   $file = $_FILES['FILE'];
   if($file['name'] != ''){
      unset($_SESSION['LIST']);
      $fu = new FileUpload($file, $dir);
      $fu->CheckFileFormat($validFile);
      $fu->UploadFile();
      $file = fopen($dir."list.txt", "r") or exit("Unable to open file!");
      //Output a line of the file until the end is reached
      while(!feof($file))
      {
         $email = fgets($file);
         $email = explode(",",$email);
         $_SESSION['LIST'][] = $email;
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
      }
      fclose($file);
   }else{
      unset($_SESSION['LIST']);
      $error = "Please locate the file";
   }
   //header("Location:$PHP_SELF");
}
if(isset($_SESSION['LIST'])){
   $i = 1;
   foreach($_SESSION['LIST'] as $key=>$val){
      $name = $val[0];
      $email = $val[1];
      $text.= "$i ."."$name - $email
";
      $i++;
   }
   print $text;
}

if(isset($_POST['SEND'])){
print_r($_POST);
if ($_POST['to'] == "all"){
	$query = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'") or die(mysql_error());
	$row = mysql_fetch_array( $query );
	$dbemail = $row['email'];

}
if ($_POST['to'] == "notall"){
	$specialization = $_POST['specialization'];
	$query = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'") or die(mysql_error());
	$row = mysql_fetch_array( $query );
	$dbemail = $row['email'];
	print_r($dbemail);

}
if ($_POST['to'] == "peremail"){
$dbemail = $_POST['email'];
}
//print_r($dbemail);

// After getting list of $dbemail, then send accordingly:
// : $mail->SendHTML($dbemail,$subject,$new_msg);
   if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";
   if($error == ""){
      require_once("Mail.php");
      $mail = new Mail();
      $mail->SetHeader($header);
  $original_msg = $_SESSION['URL'];
  $mail->SendHTML($dbemail,$subject,$original_msg);
     if(isset($_SESSION['LIST'])){
         
         foreach($_SESSION['LIST'] as $key=>$val){
            $new_msg = str_replace("%name%", $val[0], $original_msg);
		// See above
            $mail->SendHTML($val[1],$subject,$new_msg);
         }
         session_destroy();
         header("Location:$PHP_SELF");
      }
   }
}
if($active){
   $file = fopen("html.txt", "r") or exit("Unable to open file!");
   //Output a line of the file until the end is reached
   while(!feof($file))
     {
      $email .= fgets($file);
      
      //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
     }
   fclose($file);
   $email = str_replace("\"", "\\\"", $email);
   print $email;
   print "END";
}
//$bodytag = str_replace("'", "\'", $body);
echo $error;
?>
<script language="JavaScript">
function event_action(spl_value)
{
   if(spl_value=="peremail")
   {
      test.style.visibility="visible";
      test2.style.visibility='hidden';
   }
   else if(spl_value=="notall")
   {
      test2.style.visibility="visible";
      test.style.visibility='hidden';
   }
   else
   {
      test.style.visibility='hidden';
      test2.style.visibility='hidden';
   }
}
</script>
<link href="../../css.css" rel="stylesheet" type="text/css" />
<link href="../css.css" rel="stylesheet" type="text/css" />

<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
        <td width="214" valign="top"><form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <table  border="0" cellspacing="0" cellpadding="3">
            <tr>
              <td colspan="2" valign="top" nowrap="nowrap" class="text3"><img src="../images/spacer.gif" width="469" height="7" /></td>
              </tr>
            <tr>
              <td width="83" align="left" nowrap="nowrap" class="text3">Subject:</td>
              <td width="381" align="left"><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"  class="textfield1"></td>
            </tr>
            <tr>
              <td align="left" class="text3">From:</td>
              <td align="left"><input name="FROM" type="text" id="FROM" value="<?php print $header;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td align="left" class="text3">Sent to :</td>
              <td align="left"><span class="text7">
                <select name="to" class="textfield1" onchange="event_action(this.value);">
                  <option selected="selected" value="">--Email Option--</option>
                  <option value="all">Entire list</option>
                  <option value="notall">Specialization</option>
                  <option value="peremail">Individual Email</option>
                </select>
                <!--<input name="select" type="submit" id="select" value="select" />//-->
              </span></td>
            </tr>
            <!-- condition for the select menu -->
            <tr id="test2" style="visibility:hidden">
              <td align="left" class="text3">Specialization:</td>
              <td align="left"><select name="specialization" class="textfield1">
                  <option value="" selected="selected">-- Select Here --</option>
                  <?
         $uSql = "SELECT specialization FROM specialization";
         $uResult = mysql_query($uSql, $connection);
         if(!$uResult){
         echo 'no data found';
         }else{
         while($uRow = mysql_fetch_array($uResult)){
            ?>
                  <option value="<?= $uRow[specialization]?>">
                    <?= $uRow[specialization]?>
                    </option>
                  <?   }    } ?>
                </select>              </td>
            </tr>
            <tr id="test" style="visibility:hidden">
              <td align="left" class="text3">Email:</td>
              <td align="left"><input type="text" name="email" value="" class="textfield1" /></td>
            </tr>
            <!-- end -->
            <tr>
              <td align="left" class="text3">URL:</td>
              <td align="left"><input name="URL" type="text" id="URL" value="<?php print $url;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><?php if(isset($_SESSION['URL'])){?>
                  <textarea name="URLPREVIEW" cols="60" rows="10" id="URLPREVIEW" class="textfield1"><?php print $_SESSION['URL']?></textarea>
                  <br />
                  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear" />
                  <input name="AMEND" type="submit" id="AMEND" value="Change" />
                  <?php }?>
                  <input name="GETURL" type="submit" id="GETURL" value="Get URL" />              </td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><input name="SEND" type="submit" id="SEND" value="Send" />
                  <input name="CANCEL" type="submit" id="CANCEL" value="Cancel" /></td>
            </tr>
            <tr>
              <td colspan="2"><span class="text3"><img src="../images/spacer.gif" width="469" height="7" /></span></td>
              </tr>
          </table>
        </form></td>
        <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
    </table></td>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
        <td><table width="216" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
              <td width="214" valign="top"> </td>
              <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
        </table></td>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php ob_end_flush();?>

Link to comment
Share on other sites

hi,

 

how do i place a "," on each email in my entire list or specialization condition?

i tried using implode (",", $dbemail);

 

but i am getting an function.implode error on line 96

 

hope you could help me fix this

below is my code for this page

 

<?php
session_start();
ob_start();
include '../db_connect.php';
include_once("FileUpload.php");
include_once("Functions.php");
//$dir = "D:/xampp/htdocs/test/data/";
//$dir = "/home/museikne/www/misc/";
$active = false;
$error = "";
$text = "List:
";

$subject = stripslashes($_POST['SUBJECT']);
$header = isset($_POST['FROM']) ? stripslashes($_POST['FROM']) : "JobHiRings<postmaster@jobhirings.com>";
$url = isset($_POST['URL']) ? stripslashes($_POST['URL']) : "";
// Clear All
if(isset($_POST['CANCEL'])){
   //unset($_SESSION['LIST']);
   unset($_SESSION['URL']);
}
// Clear URL Content
if(isset($_POST['CLEARURL']))unset($_SESSION['URL']);
if(isset($_POST['AMEND'])){
   $_SESSION['URL'] = stripslashes($_POST['URLPREVIEW']);
}
// Get URL Content
if(isset($_POST['GETURL'])){
   if(trim($_POST['URL']) == ""){
      $error = "Please fill in the url";
   }else{
      $file = fopen($_POST['URL'], "r") or exit("Invalid URL!");
      //Output a line of the file until the end is reached
      while(!feof($file))
        {
         $body .= fgets($file);
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
        }
      fclose($file);
      //$body = str_replace("%name%", "chuyang", $body);
      $_SESSION['URL'] = $body;
   }
}

// Import name list
/*if(isset($_POST['IMPORT'])){
   $validFile = array("txt"); // valid file formats
   $file = $_FILES['FILE'];
   if($file['name'] != ''){
      unset($_SESSION['LIST']);
      $fu = new FileUpload($file, $dir);
      $fu->CheckFileFormat($validFile);
      $fu->UploadFile();
      $file = fopen($dir."list.txt", "r") or exit("Unable to open file!");
      //Output a line of the file until the end is reached
      while(!feof($file))
      {
         $email = fgets($file);
         $email = explode(",",$email);
         $_SESSION['LIST'][] = $email;
         //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
      }
      fclose($file);
   }else{
      unset($_SESSION['LIST']);
      $error = "Please locate the file";
   }
   //header("Location:$PHP_SELF");
}
if(isset($_SESSION['LIST'])){
   $i = 1;
   foreach($_SESSION['LIST'] as $key=>$val){
      $name = $val[0];
      $email = $val[1];
      $text.= "$i ."."$name - $email
";
      $i++;
   }
   print $text;
}*/

if(isset($_POST['SEND'])){
print_r($_POST);
if ($_POST['to'] == "all"){
	$query = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'") or die(mysql_error());
	while ($sendemail = mysql_fetch_array($query)){
		$dbemail = $sendemail['email'];
		echo '$dbemail';
		}
		}
if ($_POST['to'] == "notall"){
	$specialization = $_POST['specialization'];
	$query = mysql_query("SELECT email FROM applicant WHERE specialization LIKE '%".$specialization."%' AND subscribe = 'yes'") or die(mysql_error());
	while ($sendemail = mysql_fetch_array($query)){
		$dbemail = $sendemail['email'];
		$dbemail = implode(',',$dbemail);
		print_r($dbemail);
}	
}
if ($_POST['to'] == "peremail"){
$dbemail = $_POST['email'];
}
//print_r($dbemail);

// After getting list of $dbemail, then send accordingly:
// : $mail->SendHTML($dbemail,$subject,$new_msg);
   if(trim($_POST['SUBJECT'] == ""))$error = "Please fill in a subject title";
   if($error == ""){
      require_once("Mail.php");
      $mail = new Mail();
      $mail->SetHeader($header);
  $original_msg = $_SESSION['URL'];
  $mail->SendHTML($dbemail,$subject,$original_msg);
     if(isset($_SESSION['LIST'])){
         
         foreach($_SESSION['LIST'] as $key=>$val){
            $new_msg = str_replace("%name%", $val[0], $original_msg);
		// See above
            $mail->SendHTML($val[1],$subject,$new_msg);
         }
         session_destroy();
         header("Location:$PHP_SELF");
      }
   }
}
if($active){
   $file = fopen("html.txt", "r") or exit("Unable to open file!");
   //Output a line of the file until the end is reached
   while(!feof($file))
     {
      $email .= fgets($file);
      
      //mail($email,"To $email", "Hi there!", "From: ncy@museik.net");
     }
   fclose($file);
   $email = str_replace("\"", "\\\"", $email);
   print $email;
   print "END";
}
//$bodytag = str_replace("'", "\'", $body);
echo $error;
?>
<script language="JavaScript">
function event_action(spl_value)
{
   if(spl_value=="peremail")
   {
      test.style.visibility="visible";
      test2.style.visibility='hidden';
   }
   else if(spl_value=="notall")
   {
      test2.style.visibility="visible";
      test.style.visibility='hidden';
   }
   else
   {
      test.style.visibility='hidden';
      test2.style.visibility='hidden';
   }
}
</script>
<link href="../../css.css" rel="stylesheet" type="text/css" />
<link href="../css.css" rel="stylesheet" type="text/css" />

<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
        <td width="214" valign="top"><form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
          <table  border="0" cellspacing="0" cellpadding="3">
            <tr>
              <td colspan="2" valign="top" nowrap="nowrap" class="text3"><img src="../images/spacer.gif" width="469" height="7" /></td>
              </tr>
            <tr>
              <td width="83" align="left" nowrap="nowrap" class="text3">Subject:</td>
              <td width="381" align="left"><input name="SUBJECT" type="text" id="SUBJECT" value="<?php print $subject;?>"  class="textfield1"></td>
            </tr>
            <tr>
              <td align="left" class="text3">From:</td>
              <td align="left"><input name="FROM" type="text" id="FROM" value="<?php print $header;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td align="left" class="text3">Sent to :</td>
              <td align="left"><span class="text7">
                <select name="to" class="textfield1" onchange="event_action(this.value);">
                  <option selected="selected" value="">--Email Option--</option>
                  <option value="all">Entire list</option>
                  <option value="notall">Specialization</option>
                  <option value="peremail">Individual Email</option>
                </select>
                <!--<input name="select" type="submit" id="select" value="select" />//-->
              </span></td>
            </tr>
            <!-- condition for the select menu -->
            <tr id="test2" style="visibility:hidden">
              <td align="left" class="text3">Specialization:</td>
              <td align="left"><select name="specialization" class="textfield1">
                  <option value="" selected="selected">-- Select Here --</option>
                  <?
         $uSql = "SELECT specialization FROM specialization";
         $uResult = mysql_query($uSql, $connection);
         if(!$uResult){
         echo 'no data found';
         }else{
         while($uRow = mysql_fetch_array($uResult)){
            ?>
                  <option value="<?= $uRow[specialization]?>">
                    <?= $uRow[specialization]?>
                    </option>
                  <?   }    } ?>
                </select>              </td>
            </tr>
            <tr id="test" style="visibility:hidden">
              <td align="left" class="text3">Email:</td>
              <td align="left"><input type="text" name="email" value="" class="textfield1" /></td>
            </tr>
            <!-- end -->
            <tr>
              <td align="left" class="text3">URL:</td>
              <td align="left"><input name="URL" type="text" id="URL" value="<?php print $url;?>" class="textfield1" /></td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><?php if(isset($_SESSION['URL'])){?>
                  <textarea name="URLPREVIEW" cols="60" rows="10" id="URLPREVIEW" class="textfield1"><?php print $_SESSION['URL']?></textarea>
                  <br />
                  <input name="CLEARURL" type="submit" id="CLEARURL" value="Clear" />
                  <input name="AMEND" type="submit" id="AMEND" value="Change" />
                  <?php }?>
                  <input name="GETURL" type="submit" id="GETURL" value="Get URL" />              </td>
            </tr>
            <tr>
              <td> </td>
              <td align="left"><input name="SEND" type="submit" id="SEND" value="Send" />
                  <input name="CANCEL" type="submit" id="CANCEL" value="Cancel" /></td>
            </tr>
            <tr>
              <td colspan="2"><span class="text3"><img src="../images/spacer.gif" width="469" height="7" /></span></td>
              </tr>
          </table>
        </form></td>
        <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
      <tr>
        <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
      </tr>
    </table></td>
    <td><img src="../images/spacer.gif" width="6" height="10" /></td>
    <td valign="top"><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
        <td><table width="216" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
              <td width="214" valign="top"> </td>
              <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
            <tr>
              <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1" /></td>
            </tr>
        </table></td>
        <td><img src="../images/spacer.gif" width="6" height="10" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php ob_end_flush();?>

 

thanks!

Link to comment
Share on other sites

The implode() function requries an array as it's input, and pulling an array directly out of a SQL query won't work for that.

 

Try replacing this code:

 

if ($_POST['to'] == "all"){
	$query = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'") or die(mysql_error());
	while ($sendemail = mysql_fetch_array($query)){
		$dbemail = $sendemail['email'];
		echo '$dbemail';
		}
		}
if ($_POST['to'] == "notall"){
	$specialization = $_POST['specialization'];
	$query = mysql_query("SELECT email FROM applicant WHERE specialization LIKE '%".$specialization."%' AND subscribe = 'yes'") or die(mysql_error());
	while ($sendemail = mysql_fetch_array($query)){
		$dbemail = $sendemail['email'];
		$dbemail = implode(',',$dbemail);
		print_r($dbemail);
}	
}
if ($_POST['to'] == "peremail"){
$dbemail = $_POST['email'];
}

 

... with something like this ...

 

$dbemail = array();
if ($_POST['to'] == "all"){
	$query = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'") or die(mysql_error());
	while($row = mysql_fetch_array( $query )){
		$dbemail[] = $row['email'];
	}
}
if ($_POST['to'] == "notall"){
	$specialization = $_POST['specialization'];
	$query = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'") or die(mysql_error());
	while($row = mysql_fetch_array( $query )){
		$dbemail[] = $row['email'];
	};

}
if ($_POST['to'] == "peremail"){
	$dbemail[] = $_POST['email'];
}

 

... and then change this line ...

 

$mail->SendHTML($dbemail,$subject,$original_msg);

 

... to use the implode() function on the $dbemail array ...

 

$mail->SendHTML(implode(",", $dbemail),$subject,$original_msg);

 

 

Link to comment
Share on other sites

Hi,

 

Thanks its working now.

but i got another problem.

definitely the people where i emailed will get mad at me because, they can

see each other's email address.

 

How do i set it up so that there there email will be in bcc or

maybe will be sent to all the email list 1 at a time?

 

hope you could help me on the codes for this.

 

thanks!

Link to comment
Share on other sites

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.