我主要有一个表单,以便可以处理多个名称和电子邮件地址,这个其他 PHP 文件处理该表单,以便它使用 mail() 发送到这些电子邮件。我在表单上使用了循环,以便将输入字段重复到多个条目然后提交。所以表格看起来像这样:
<?php for ($i = 1; $i <= 10; $i++) { ?> // here's the PHP loop
<input type="text"
id="<?php echo 'firstname'.$i ?>" name="<?php echo 'firstname'.$i; ?>"
value="<?php echo $_GET['firstname']; ?>" />
value?
<br/>
<input type="text" id="<?php echo 'lastname'.$i; ?>"
name="<?php echo 'lastname'.$i; ?>"
value="<?php echo $_GET['lastname']; ?>" />
<input type="text" id="<?php echo 'email'.$i; ?>"
name="<?php echo 'email'.$i; ?>"
value="<?php echo $_GET['email']; ?>"/>
<?php } ?> // END of loop
<input class="button" type="submit" value="Submit" name="submit" />
所以现在我对处理上述内容的第二个 PHP 文件感到两次困惑。我如何在每封电子邮件中回显一条消息,但使用上面输入字段中的值。我不确定我是否使用爆炸,因为输入的值在数组中?换句话说,每封电子邮件都必须分别向它们发送一条消息。
extract($_GET, EXTR_PREFIX_SAME, "get");
#construct email message
$email_message = "Name: ".$firstname." ".$lastname."
Email: ".$email;
#construct the email headers
$to = "email something";
$from = $_GET['email'];
$email_subject = "Registration Details";
#now mail
mail($to, $email_subject, $email_message, "From: ".$from);
echo "<b>Thank you ".$firstname." ".$lastname."! You are now registered.</b><br/><br/>";
echo "Here's your registration information:<br/><br/>";
echo "Email: ".$email."<br/>";