THANKS! That helped a lot....only thing now is that while it sends to all of my addresses when I select the "all" option it doesn't send to individual email addresses when I select a specific address.....
Error is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/esbsolu/public_html/email.php on line 94
here's my code reposted. THANKS IN ADVANCE!
<?php session_start();
// check session variable
if (isset($HTTP_SESSION_VARS['valid_user']))
{
?>
<?include("headerdb.php");?>
<h3>Mailing List Admin</h3>
</td></tr>
<tr><td valign="top" cellspacing="0" cellpadding="0">
<form method="post" action="<?php echo $PHP_SELF; ?>">
<?php
$db = @mysql_connect('localhost', 'user', 'pass');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.<br /><br /><br /><br /><br /><br /><br />';
exit;
}
mysql_select_db('esbsolu_esbcontact');
if(!$submit)
{
?>
<table align="center" bgcolor="#D6DEE7" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
Send message to:
<select name="to" size="1" style="background-color: #F7F7F7">
<option selected value="all">All clients
<option value="notall">By client
</select>
Client:
<select name="client" size="5">
<OPTION value="Yahoo Harris">Yahoo
<OPTION value="ESB Harris">Esbsolutions
<OPTION value="Sozezad">Zoze
<OPTION value="Dad">Dad
</select>
Title or Subject: <input name="subject" type=text maxlength=100 size=40>
Message:
<textarea wrap name="message" rows=10 cols=45></text>
<input type=submit name="submit" value="SUBMIT">
</td>
</tr>
</table>
<?php
}
else
{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$client = $_POST['client'];
if ($to == "all")
{
$x = 1;
$hold = 50;
// quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT * FROM contact");
while ($sendemail = mysql_fetch_array($emails))
{
$email = $sendemail["Email"];
mail($email, $subject,
$message, "From:Eastern Seaboard Solutions <mail@esbsolutions.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;
}
}
}
if ($to == "notall")
{
$byclient = mysql_query("SELECT * FROM contact WHERE client=$Name");
while ($countmail = mysql_fetch_array($byclient))
{
$email = $countmail["Email"];
$okemail = mail($email, $subject,
$message, "From:Eastern Seaboard Solutions <mail@esbsolutions.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 'Emails were successfully sent.';
}
mysql_close($db);
}
else
{
?>
</form>
<?include("headerdb.php");?><br /><br />
You are not logged in.<br /><br />
<a href="authentication.php" class="rollmain">Log in</a> or return to the <a href="main.php" class="rollmain">main website.</a>
<?php
}
?>
</td></tr>
<?include("footer.php");?>