Jump to content

need help on my emailer sender


pixeltrace

Recommended Posts

guys,

 

i need help, i have a emailer sender form which is meant to send to either, indivual, per group or entire email list in my database.

my problem now, its now working and i am getting some error messages which i cannot

fix.

 

the error message is

Parse error: parse error, unexpected $end in c:\hosting\webhost4life\member\diorgrace\admean\email\blast.php on line 173

 

this is the code for my page

<?
session_start();
if (session_is_registered("username")){
include("../db_connect.php");
   if (!isset($_POST['submit'])):
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization">
                          <option value="" selected="selected">-- select specialization 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>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right">per email : </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="Add Candidate" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>
	<?php else: 

  $to = $_POST['to'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $specialization = $_POST['specialization'];

  if ("all" == $to) {
   $x = 1;
   $hold = 50; // quantity of emails sent before 3 sec delay
   $emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
   while ($sendemail = mysql_fetch_array($emails)) {
   $email = $sendemail["email"];
   mail($email, $subject,
   $message, "From:JobHiRings <posmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
    }
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop
  } elseif ("notall" == $to) {
   $byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
   while ($countmail = mysql_fetch_array($byspecialization)) {
   $email = $countmail["email"];
   $okemail = mail($email, $subject,
   $message, "From:JobHiRings <postmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
    }
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop
  } elseif ("peremail" == $to) {
   $email = $_POST["peremail"];
   $okemail = mail($email, $subject,
   $message, "From:JobHiRings <postmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop

?>

	<?
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}
?>

 

 

hope you could help me with this.

 

thanks!

Link to comment
Share on other sites

Your first if statement does not have { } around it, try adding those as anything that displays more than one line or processes mroe than one line in an if require the { }. When you get the parse error $end it generally means you are not closing a { } somewhere.

Link to comment
Share on other sites

hi,

 

i dont see the errors now,

but when i try sending an email here to my email address.

i dont receive any emails

hope you could help me fix the error

below is my codes for this page

 

<?
include("db_connect.php");
   if (!isset($_POST['submit'])):
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization 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>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>
	<?php else: 

  $to = $_POST['to'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $specialization = $_POST['specialization'];

  if ("all" == $to) {
   $x = 1;
   $hold = 50; // quantity of emails sent before 3 sec delay
   $emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
   while ($sendemail = mysql_fetch_array($emails)) {
   $email = $sendemail["email"];
   mail($email, $subject,
   $message, "From:JobHiRings <posmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
    }
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop
  } elseif ("notall" == $to) {
   $byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
   while ($countmail = mysql_fetch_array($byspecialization)) {
   $email = $countmail["email"];
   $okemail = mail($email, $subject,
   $message, "From:JobHiRings <postmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
    }
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop
  } elseif ("peremail" == $to) {
   $email = $_POST["peremail"];
   $okemail = mail($email, $subject,
   $message, "From:JobHiRings <postmaster@jobhirings.com>");

   $x++;
    if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
    sleep(3);
    $x = 0;
echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
   } // end of while loop
}
?>
<?php endif; ?>

 

thanks!

Link to comment
Share on other sites

OK

 

try this let me know what problems exist

 

i cleaned it up a but

 

<?php
include("db_connect.php");
if ( !isset($_POST['submit']) )
{
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization here --</option>

<?php
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
			echo 'no data found';
		}else{
			while($uRow = mysql_fetch_array($uResult))
			{
				echo "<option value='{$uRow[specialization]}'>/n";
				echo "{$uRow[specialization]}/n";
				echo "</option>/n";
			}    
		}
		?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>



<?php
}else{
  $to = $_POST['to'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $specialization = $_POST['specialization'];

if ("all" == $to)
{
	$x = 1;
	$hold = 50; // quantity of emails sent before 3 sec delay
	$emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
	while ($sendemail = mysql_fetch_array($emails))
	{
		$email = $sendemail["email"];
		mail($email, $subject,
		$message, "From:JobHiRings <posmaster@jobhirings.com>");

		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
}elseif("notall" == $to)
{
	$byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
	while ($countmail = mysql_fetch_array($byspecialization))
	{
		$email = $countmail["email"];
		$okemail = mail($email, $subject,
			$message, "From:JobHiRings <postmaster@jobhirings.com>"
		);
		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
}elseif ("peremail" == $to){
	$email = $_POST["peremail"];
	$okemail = mail($email, $subject,
	$message, "From:JobHiRings <postmaster@jobhirings.com>");

	$x++;
	if($x == $hold)
	{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
		sleep(3);
		$x = 0;
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
}
}
?>

Link to comment
Share on other sites

what select did you use ?

  • Entire list
  • Specialization
  • Individual Email

 

PS heres a cleaner script

 

<?php
include("db_connect.php");
if ( !isset($_POST['submit']) )
{
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization here --</option>

<?php
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
			echo 'no data found';
		}else{
			while($uRow = mysql_fetch_array($uResult))
			{
				echo "<option value='{$uRow[specialization]}'>/n";
				echo "{$uRow[specialization]}/n";
				echo "</option>/n";
			}    
		}
		?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>



<?php
}else{
  $to = $_POST['to'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $specialization = $_POST['specialization'];

switch($to)
{
case "all":
	$x = 1;
	$hold = 50; // quantity of emails sent before 3 sec delay
	$emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
	while ($sendemail = mysql_fetch_array($emails))
	{
		$email = $sendemail["email"];
		mail($email, $subject,
		$message, "From:JobHiRings <posmaster@jobhirings.com>");

		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "notall":
	$byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
	while ($countmail = mysql_fetch_array($byspecialization))
	{
		$email = $countmail["email"];
		$okemail = mail($email, $subject,
			$message, "From:JobHiRings <postmaster@jobhirings.com>"
		);
		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "peremail":
	$email = $_POST["peremail"];
	$okemail = mail($email, $subject,
	$message, "From:JobHiRings <postmaster@jobhirings.com>");

	$x++;
	if($x == $hold)
	{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
		sleep(3);
		$x = 0;
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;

}

}
?>



Link to comment
Share on other sites

hi,

 

i tried testing it for the individual email

i still cant get my test mail

 

and another thing, when sending, its not even prompting the

javascript telling me that the email alert has been submitted.

 

this is the current code that you gave me

<?php
include("db_connect.php");
if ( !isset($_POST['submit']) )
{
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization here --</option>

<?php
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult){
			echo 'no data found';
		}else{
			while($uRow = mysql_fetch_array($uResult))
			{
				echo "<option value='{$uRow[specialization]}'>/n";
				echo "{$uRow[specialization]}/n";
				echo "</option>/n";
			}    
		}
		?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>



<?php
}else{
  $to = $_POST['to'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $specialization = $_POST['specialization'];

switch($to)
{
case "all":
	$x = 1;
	$hold = 50; // quantity of emails sent before 3 sec delay
	$emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
	while ($sendemail = mysql_fetch_array($emails))
	{
		$email = $sendemail["email"];
		mail($email, $subject,
		$message, "From:JobHiRings <posmaster@jobhirings.com>");

		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "notall":
	$byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
	while ($countmail = mysql_fetch_array($byspecialization))
	{
		$email = $countmail["email"];
		$okemail = mail($email, $subject,
			$message, "From:JobHiRings <postmaster@jobhirings.com>"
		);
		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "peremail":
	$email = $_POST["peremail"];
	$okemail = mail($email, $subject,
	$message, "From:JobHiRings <postmaster@jobhirings.com>");

	$x++;
	if($x == $hold)
	{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
		sleep(3);
		$x = 0;
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;

}

}
?>

 

whatelse could be wrong here?

thanks!

Link to comment
Share on other sites

Heehee i notice the error in the code for that

 

OK

 

This works on my server i sent them to my hotmail but when ended up in my junk email folder.. try now o hope this works :D


<?php
include("db_connect.php");
if ( !isset($_POST['submit']) )
{
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization here --</option>

<?php
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult)
		{
			echo 'no data found';
		}else{
			while($uRow = mysql_fetch_array($uResult))
			{
				echo "<option value='{$uRow[specialization]}'>/n";
				echo "{$uRow[specialization]}/n";
				echo "</option>/n";
			}    
		}
		?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>



<?php
}else{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$specialization = $_POST['specialization'];

switch($to)
{
case "all":
	$x = 1;
	$hold = 50; // quantity of emails sent before 3 sec delay
	$emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
	while ($sendemail = mysql_fetch_array($emails))
	{
		$email = $sendemail["email"];
		mail($email, $subject,
		$message, "From:JobHiRings <posmaster@jobhirings.com>");

		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "notall":
	$byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
	while ($countmail = mysql_fetch_array($byspecialization))
	{
		$email = $countmail["email"];
		$okemail = mail($email, $subject,
			$message, "From:JobHiRings <postmaster@jobhirings.com>"
		);
		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "peremail":
	$email = $_POST["peremail"];
	$okemail = mail($email, $subject,
	$message, "From:JobHiRings <postmaster@jobhirings.com>");
	$x++;
	if(okemail)
	{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
		sleep(3);
		$x = 0;
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;

}

}
?>


Link to comment
Share on other sites

i get this when I went to your testpage:

 

Warning: main(db_connect.php) [function.main]: failed to open stream: No such file or directory in c:\hosting\webhost4life\member\diorgrace\admean\email\blast.php on line 2

 

Warning: main() [function.include]: Failed opening 'db_connect.php' for inclusion (include_path='.;c:\php\pear') in c:\hosting\webhost4life\member\diorgrace\admean\email\blast.php on line 2

 

just wanted to let you know =)

Link to comment
Share on other sites

this is the code that MadTechie gave me

 

<?php
include("../db_connect.php");
if ( !isset($_POST['submit']) )
{
?> 
	<table width="100" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="6" align="left"><img src="../images/spacer.gif" width="6" height="10" /></td>
            <td width="100%"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
              <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"><table width="558" border="0" cellspacing="2" cellpadding="3">
                      <tr>
                        <td colspan="3" valign="top"><img src="images/spacer.gif" width="10" height="1" /></td>
                      </tr>
                      <tr>
                        <td colspan="3" bgcolor="#999999" class="text2">SEND EMAIL ALERTS </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td width="119" align="right" valign="top" class="text6">send by   :</td>
                        <td> </td>
                        <td width="412" class="text7">
					<select name="to" class="textfield1">
					<option selected value="all">Entire list</option>
					<option value="notall">Specialization</option>
					<option value="peremail">Individual Email</option>
					</select> 

                          </select></td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">by specialization   : </span></td>
                        <td> </td>
                        <td><select name="specialization" class="textfield1">
                          <option value="" selected="selected">-- select specialization here --</option>

<?php
		$uSql = "SELECT specialization FROM specialization";
		$uResult = mysql_query($uSql, $connection);
		if(!$uResult)
		{
			echo 'no data found';
		}else{
			while($uRow = mysql_fetch_array($uResult))
			{
				echo "<option value='{$uRow[specialization]}'>/n";
				echo "{$uRow[specialization]}/n";
				echo "</option>/n";
			}    
		}
		?>
                        </select></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if by specialization, please select one here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">per email :</span> </td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="peremail" type="text" class="textfield" maxlength="100" size="40" />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right"> </td>
                        <td> </td>
                        <td class="text7">*if per email, please input the email address here </td>
                      </tr>
                      <tr>
                        <td align="right"><span class="text6">subject  :</span></td>
                        <td> </td>
                        <td><span class="text7">
                          <input name="subject" type="text" class="textfield" maxlength=100 size=40>
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td align="right" valign="top" class="text6"> </td>
                        <td valign="top" class="text7"> </td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6"><hr></td>
                      </tr>
                      <tr>
                        <td colspan="3" valign="top" class="text6">HTML BODY: copy & paste the HTML page here <span class="text7"></span> </td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><textarea id="elm1" name="message" rows="35" cols="80" style="width: 100%"></textarea></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"><input type="submit" name="submit" value="send" class="textfield1" />
<input type=hidden value=http://www. name=redirect></td>
                      </tr>
                      <tr>
                        <td colspan="3" align="center" valign="top" class="text6"> </td>
                      </tr>
                  </table></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>
            </form></td>
            <td width="6" align="right"><img src="../images/spacer.gif" width="6" height="10" /></td>
          </tr>
        </table>



<?php
}else{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$specialization = $_POST['specialization'];

switch($to)
{
case "all":
	$x = 1;
	$hold = 50; // quantity of emails sent before 3 sec delay
	$emails = mysql_query("SELECT email FROM applicant WHERE subscribe = 'yes'");
	while ($sendemail = mysql_fetch_array($emails))
	{
		$email = $sendemail["email"];
		mail($email, $subject,
		$message, "From:JobHiRings <posmaster@jobhirings.com>");

		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "notall":
	$byspecialization = mysql_query("SELECT email FROM applicant WHERE specialization = '$specialization' AND subscribe = 'yes'");
	while ($countmail = mysql_fetch_array($byspecialization))
	{
		$email = $countmail["email"];
		$okemail = mail($email, $subject,
			$message, "From:JobHiRings <postmaster@jobhirings.com>"
		);
		$x++;
		if($x == $hold)
		{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
			sleep(3);
			$x = 0;
		}
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;
case "peremail":
	$email = $_POST["peremail"];
	$okemail = mail($email, $subject,
	$message, "From:JobHiRings <postmaster@jobhirings.com>");
	$x++;
	if(okemail)
	{ // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
		sleep(3);
		$x = 0;
		echo '<script language=javascript> alert("Email alert has been submitted!");top.location = "emailalert.php?id=1";</script>';
	} // end of while loop
break;

}

}
?>

 

 

and you can check the link here

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

 

 

hope you could help me with 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.