Hi NewDog!
1) How can I exclude null/blank entries in the database from the drop down list?
Just exclude them from your query! I use this:
$sql = 'SELECT concat(\'\n\t<option value="\',email,\'">\',name,\'</option>\') AS options FROM table WHERE email <> ""';
$result = mysql_query($sql, $db) or die(mysql_error());
echo "\n<select name=\"email\">";
while($row = mysql_fetch_assoc($result)) {
echo $row['options'];
}
echo "\n</select>";
2) Is it possible for the user to select and then send to multiple email addresses from the drop down ??? - what function could I use?
It certainly is possible, and it's not particularly hard, either!
In your html, you need to do 3 things. First of all, take out all value attributes from your <option> tags. Secondly, you need to set the select name to an array, like this: <select name="select[]">, and finally you need to give the select tag 2 more attributes, multiple and size, so it will end up looking like this:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<select name="email[]" multiple="multiple" size="5">
<option>Value1</option>
<option>Value2</option>
<option>Value3</option>
<option>Value4</option>
</select>
<input type="submit" name="submit" value="go">
</form>
Then, after you've done this to the html, you would just set your $Address_to like so:
unset($Address_to);
foreach($_POST['email'] as $k=>$v) {
$Address_to .= $v.";";
}
Pretty easy, huh?!? 🙂
3) Is it possible to verify the sender's address and then send a copy of the email to the sender (or use a checkbox if the sender wants one - I think I can figure out the checkbox issue).
If by verify you want to physically check if that address exists, then no, it's not possible, unless you have a database of every known email address 😉 However, you can check the format to make sure that it's correct. I use this regular expression that I wrote:
[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)+$
You use this with the ereg function like so:
$email_regex = "^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$";
if(ereg($email_regex, $email)) {
echo "VALID!";
} else {
echo "INVALID";
}
I would suggest you don't blindly use that without understanding it, but instead read up on POSIX regular expressions. You might also want to read up on PCRE regular expressions, because they can sometimes be much more powerful and efficient 🙂
Then, all you have to do is send another mail like you're doing, using the sender's address 🙂
Hope that helps,
Matt