PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Aug 24, 2019 6:22 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Aug 10, 2010 2:08 am 
Offline
Forum Newbie

Joined: Tue Aug 10, 2010 2:01 am
Posts: 1
Hi,

I am developing a simple application mailing system in which i need to place a check box in a listbox,which having emails id from database. How do i do it?...For example in the mailing system application , when i have to send a email, it displays all the emails as a list with checkbox where in i can select any emails from the list or the options i choose select All.here is my code.......


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send e-mails</title>

<?php
$from = "mail@mail.com";

$mesa = $_POST['mess'];
$subje = $_POST['subj'];
$mails = $_POST['mail'];



?>

<link rel="stylesheet" href="stylesheet.css"> <!-- Main Stylesheet -->

</head>

<body style="margin: 1px; font-family: arial, verdana, san-serif; font-size: 14px;">
<table width="80%" border="1" align="center">
<tr>
<td><div align="right">
Add new e-mail <a href="index1.php"><font color=#005aee>Here</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='logout.php'>Logout</a></div>
</td>
</tr>

<tr>
<td>

<table>
<tr>
<td>

<table>
<tr>
<td>

<form name=mailids>
<select name=test multiple size=26 style="width: 200px;">

<?php

include("connect.php");
$query="SELECT email FROM emails ORDER BY email";
$rs = mysql_query($query);

while($row = mysql_fetch_array($rs))
{

echo"<option>".$row['email']."</option>";//here i need option checkboxes along with emails
}

?>


</select>
</form>

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

<!-- To add required code to make the milids selected after sending mail -->
<!--script language=javascript>
document.mailids.test[0].selected = true;
</script-->

<td>
<table>
<tr>
<td>
<form name=message method=post action="<?php $PHP_SELF?>">
<br>
FROM :<br>
<input name=from value=<?php echo "$from";?> type=text size=59 readonly>
<br><br>
Subject:<br>
<input name=subj value="<?php echo($subje); ?>" type=text size=59><br><br>
Message:<br>
<textarea name="mess" rows=16 cols=50 wrap=physical><?php echo($mesa); ?></textarea>
<input type=hidden name=mail>
<br><br>

<br><br>
<input type=submit value="Send Mail" onClick="submitForm()">
</form>

<script language=javascript>
function submitForm()
{
var subject = document.message.subj.value;

if(subject.length == "")
{
alert("Please give a proper subject");
return false;
}

var message = document.message.mess.value;

if(message.length == "")
{
alert("Please give a proper message");
return false;
}


var tot = document.mailids.test.length;
var maildis = "";
for(i=0; i<tot; i++)
{
if(document.mailids.test[i].selected == true)
{
var ssr = document.mailids.test[i].value;
maildis = maildis+"||"+ssr;
document.message.mail.value = maildis;
}
}

var maaa = document.message.mail.value;
echo(maaa);
document.message.submit();
}
</script>

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

</tr>
</table>

</td>
</tr>

</table>
<table align="center">
<tr>
<td>

<?php
$tok = strtok($mails, " ||");
echo("Mail sent to:");


$message1 = str_replace("
", "\n", $mesa);
$message1 = str_replace("\\\\","",$message1);
$message1 = str_replace("\'","'",$message1);
$message1 = str_replace("\\\"","\"",$message1);
$message1 = nl2br($message1);

while ($tok)
{
/* additional headers */
/* To send HTML mail, you can set the Content-type header. */

$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers1 .= "To: ".$tok."\r\n";
$headers1 .= "From: ".$from."\r\n";
$headers1 .= "Reply-To: ".$from."\r\n";
$headers1 .= "Cc: \r\n";

echo("<font color=green> $tok </font>");
if(@mail($tok,$subje,$message1,$headers1))
{
echo("-<font color=#005aee> Mail Sent Successfully </font>,");
}
else
{
echo("-<font color=red>Mail Not Sent </font>,");
}
$tok = strtok("||");
}
?>
</td>
</tr>
</table>


</body>
</html>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group