I want to sent email to all enews subcribers but how can i send mail more than one person but when i used this coding its working not properly.it is send 3 times mails to one person
plz help me

<?php
// Connects to your Database 
include("connection.php");


?>





<link href="../log.css" rel="stylesheet" type="text/css" />


<?php
// Connects to your Database 
include("connection.php");


?>





<link href="../log.css" rel="stylesheet" type="text/css" />



<?php 


 
 //checks cookies to make sure they are logged in 

 if(isset($_COOKIE['ID_my_site'])) 

 { 

 	$username1 = $_COOKIE['ID_my_site']; 

 	$pass1 = $_COOKIE['Key_my_site']; 

 	 	$check = mysql_query("SELECT * FROM acl WHERE un = '$username1'")or die(mysql_error()); 

 	while($info = mysql_fetch_array( $check )) 	 

 		{ 

 

 //if the cookie has the wrong password, they are taken to the login page 

 		if ($pass1 != $info['password']) 

 			{ 			header("Location: index.php"); 

 			} 

 

 //otherwise they are shown the admin area	 

 	else 

 			{ 

 			 echo "<span class=\"he\"  style=\"color:#69B521;\"  >HI ".strtoupper("$username1</span> ");
			 echo $info['user_id']; 
 echo ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <span class="bu" >
<a href="logout.php" style="text-decoration:none;">
 <input type="submit" name="submit" value="Login"></input> 
</a>
</span>'; 

?>


<?php
 			} 

 		} 






?>


<?php
 		} 

 else 

 

 //if the cookie does not exist, they are taken to the login screen 
 {			 

 header("Location: index.php"); 

 } 
 
 
 echo $check['ID']
 

 ?> 

  <table width="100%" border="0" id="alin">
    <tr  style="vertical-align:middle; text-align:left;">
    <form action="" name="myform" id="myform" method="post">

      <td width="16%" height="92"><span class="se"> PLese TYPE
            <textarea type="textarea" width="200px" height="200px" name="message" /> 
            </textarea>         </span>
</td>
<tr>
      <td width="84%"><span class="seb" >           <input type="submit" value="Submit" name="btn" />  </span>
</td>
</tr>
</form>
    </tr>
  </table>
  
  <?php
  
  if(isset($_POST["btn"]))
{
  
  	$selectadd=mysql_query("SELECT * FROM enew ");
		

	while($loopadd=mysql_fetch_array($selectadd))	
{
?>
  <table width="184" border="0">
    <tr width="200px">
      <td width="100px" height="50px" style="text-align:left; vertical-align:top;">
	  <p style="text-align:left;"><?php echo $loopadd['enew_id']; ?></p></td>

      <td width="100px" height="50px" style="text-align:left; vertical-align:top;">
	  <p style="text-align:left;"><?php echo $loopadd['enew_email']; ?></p></td>
      
            <td width="100px" height="50px" style="text-align:left; vertical-align:top;">
	  <p style="text-align:left;"><?php echo $loopadd['enew_user']; ?></p></td>
                  <td width="100px" height="50px" style="text-align:left; vertical-align:top;">
	  <p style="text-align:left;"><?php echo $_POST['message']; ?></p></td>
            <td width="100px" height="50px" style="text-align:left; vertical-align:top;">
     <?php 
$to =$loopadd['enew_email'];
$subject = "Test mail";
// Your message
$message=$_POST['message'];

$from="zohaib@sikone.com";
$sentmail = mail($to,$subject,$message,$from);
if($sentmail)
{
	echo ("send");
}
else
{
	echo ("Error");


}

?>
      
</td>      
    </tr>
  </table>

<?php 
}
  
}
else
{
	die ("Not SEnding") ;
}
  
  
  
      ?>

<?php


	
?>
  <p><br>
  <?php



?>

echo out your line 155 as follows and see the o/p.

echo $to =$loopadd['enew_email'];

my code is working but sending mail one person 3 times means one person getting mail more than one time plz rply me soon

Be a part of the DaniWeb community

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