Reputation: 148
I have a form with 9 text fields where users can input their friends' emails. The recipients will receive HTML email in their inbox.
Question, how do I make it so that the users don't have to input in all the 9 text fields? As for now, when I just enter an email on 1 field, they will display 8 errors (for each unfilled text field)
Warning: mail() [function.mail]: SMTP server response: 503 Bad sequence of commands. You must specify the recipients of a message before you can send it in C:\httpdocs\PRM\mail-ori.php on line 62
Upvotes: 0
Views: 951
Reputation: 8726
Your Form fields.
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
<input type="text" name="email[]" />
If you remove the nulls your program will not throw any errors. Write this bellow condition in action form.
<?php
$AllEmails=$_REQUEST['email'];
// To remove nulls.
$emails=array_filter($AllEmails);
for($itr=0; $itr<count($emails); $itr++)
{
echo "Sent the mail to mail_ID: ".$emails[$itr];
}
?>
Upvotes: 3