Variable value lost in mailto: bcc

The following script retrieves emails from a MYSQL database. I’m taking the group of emails, setting them in a variable, and sending them using HTML’s mailto: function. The href link works great, but I’d prefer to use a button. When I bring the variable into the form action, it is empty… but only in the BCC section. I tried putting the variable directly after the mailto: as the primary recipient and it was not empty. Why is it empty in the BCC section of the form?

Here is the relevant code:

$q = "SELECT email FROM volunteers WHERE $column ='y'";
$r = @mysqli_query ($dbc, $q);
$group = array();
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$group[] = $row['email'];
$groupemail = implode(', ', $group);

echo '<form action="' . $groupemail . '">
<input type="submit" value="Email All">
echo '<a href="' . $groupemail . '">Email All</a>';

mysqli_free_result ($r);

Do you see that value in page source from browser?

This is not valid. Modern and even many not so modern browsers will disregard the form completely and try to open an attached email program - assuming the browser is set up with one defined.

You need to either use an <a> tag to attach the mailto: or use a form2mail script with the form.

The use of @ to suppress errors is always a bad idea, you should be using exceptions to handle any errors thrown back by MySQL.

For a development version of a site you should display the errors but for a live site you should log any errors to a log

Thank you. I wanted to use the form just for aesthetic purposes, but realistically only two or three people will ever see or use this page. An <a> tag will do.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.