Hi,
I am trying to make a mail sending application where i need to get the selected emails to a form where there is a text area .... Here is the code i am using
mailForm.php
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
echo '<h3>Send Mail</h3>';
echo '<form action="" method="post">
<p><label>To:</label><textarea cols="100" rows="5" name="addresses" readonly>'.$email.'</textarea></p>
<p><label>Subject:</label><textarea cols="100" rows="1" name="subject" ></textarea></p>
<p><label>Subject:</label><textarea cols="100" rows="20" name="body" ></textarea></p>
<p><input type="submit" value="send mail"><input type="reset" value="cancel"></p>
</form>';
?>
Think there is a problem with giving $email instead of an array ..
Here is the admin code ..
There are two buttons for sending mail ..... One to send single mail and the other to send mails to multiple addresses ...
echo '<form id="admin" action="./sendMail.php" method="post">';
echo '<table>';
while($row=mysql_fetch_assoc($result))
{
echo'<tr ><td>'.$i++.' </td><td><input type="checkbox" name="edit[]" value='.$row['id']. '></td><td>'. $row['email'] . '</td><td>'. strtolower($row['fname'] ." ". $row['lname']) . ' </td><td>';
echo '</a> </td><td><a href="sendMail.php?id='.$row['id'].'"><img src="images/mail.png"></a></td>';
echo '</table>';
echo '<button class="noborder" type="submit" name="submit_mult" value="mail"><img src="images/mail.png"></button></br> ';
echo '</form>';
Next is the sendMail.php
if (isset($_REQUEST['submit_mult']))
{
if(count($_POST[edit])>0)
{
foreach($_POST[edit] as $row[id])
{
$sql="select email from users where users.id = $row[id]";
if( mysql_query($sql))
$email=mysql_fetch_row(mysql_query($sql));
echo $email[0].",";
}
$email ="Mails";
}
else
{
$email= "No Mail selected";
}
}
else{
$sql="select email from users where users.id=$_REQUEST[id]";
$row=mysql_fetch_row(mysql_query($sql));
$email= $row[0];
}
include 'mailForm.php';
When i click to get single mail id it is working nice ...
I am getting comma separated values in the array while selecting multiple mails too (though there is a comma at the end 🙁 ) .. .. but i cant display them in textarea ... can anybody suggest how to handle this .. to display an array in text area ... Thanks in advance for any help and time you spend ....