I have a problem. I did a form with i can choose who goes it with "checkbox"
The problem is the message is just going to the 2nd destiantion (2nd checkbox), and ignore the other checked.
Can anybody help? Thks
exemple of my code:
...(begining)...
<form action="<?$_SERVER['PHP_SELF']; ?>" method="post">
...(somewhere in the form)...
<input type="checkbox" name="emailto" id="emailto1" value="mail@xxx.com">MV
<input type="checkbox" name="emailto" id="emailto2" value="mail@xxx.com">
...(before all form)...
<?
if ($_POST['submit']){
$titulo = "** BRIEF **";
$sender = "BRIEF<sender@xxx.com>";
$to = $_POST ['emailto'];
$reply = "sender@xxx.com";
$mensagem = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body>
test
</body>
</html>";
mail($to, $titulo,开发者_Python百科 $mensagem,"From:$sender\r\nReply-to:$reply\r\nContent-type: text/html; charset=iso-8859-1");
echo "<b><font face='Verdana' color='#C10000' size='2' align='center'>Dados enviados com sucesso.</b></font>";
}
?>
...
`
write name="emailto[]"
and see the data
echo "<pre>";
print_r($_POST['emailto']);
it's an array of email
As for as I have understood your problem you should work with array. Changed the names of your checkboxes with array like this.
<input type="checkbox" name="emailto[]" id="emailto1" value="xxx@xx.com"> <span class="font_bold_01">PG + MV <input type="checkbox" name="emailto[]" id="emailto2" value="xxx@xx.com"> PG + MV + VC
On other hand use loop to get all checked values. Hope it is the answer
精彩评论