Hello,
I have to create a script for a client.
So i did that.
The intetnion of this script was:
I have to mail people, i want to select those people by boxes.
But,very important, i will not allow people to see thier email adresses. Not even when they get mailed.
I thought this could be solved with an system of selecting an username then get the email for that username and then mail it via cc: or Bcc: but it wont work.....
My scripts:
selecting
<html>
<body>
<form method="POST" action="send.php">
<select size="5" name="email[]" multiple>
<?php
$db = mysql_connect("XXX","XXX","XXX");
mysql_select_db("XXX");
$sql="SELECT username FROM users ORDER BY user_level DESC";
$res=mysql_query($sql, $db);
while ($ligne = mysql_fetch_object ($res))
{
?>
<option><?php echo $ligne->username; ?></option>
<?php
}
mysql_free_result ($res);
mysql_close($db);
?>
</select>
<input type="text" value="Auteur" name="auth">
<input type="text" value="onderwerp" name="sub">
<input type="text" value="Bericht" name="msg">
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</body>
</html>
The proccesing script:
<html>
<?php
$subject = $_POST['sub'];
$message = $_POST['msg'];
$header = "cc: ";
$mails = $_POST['auth'];
$array = array();
mysql_connect("XXX","XXX","XXX");
mysql_select_db("XXX");
for ($i=0;$i<count($_POST['email']);$i++)
{
$adres = $_POST['email'][$i];
$sql = mysql_query("SELECT email_address FROM users WHERE username='$adres'");
$row = mysql_fetch_array($sql);
If ($i == "0")
{
$header .= $row['email_address']."\r\n Bcc: ";
}
Else
{
$array[] .= $row['email_address'];
}
}
mysql_close();
$header .= implode(",", $array);
$header .= "\r\n FROM: <streetfreaks@streetfreaks.nl>";
imap_mail($mails,$subject,$message,$header);
// This is used for testing purpose.
echo "Auteur: ".$mails."<br>";
echo "Onderwerp: ".$subject."<br>";
echo "Bericht: ".$message."<br>";
echo "Header: ".$header;
?>
</html>
I hope someone could help me.
Btw i said against that client i was an beginner with PHP.
So that you all don't think i'm an lair.:o