私は主に、複数の名前と電子メールアドレスを処理できるフォームを持っています。この他の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" />
そのため、上記を処理するための2番目のPHPファイルで2回混乱しています。上記の入力フィールドの値を使用して、電子メールごとにメッセージをエコーするにはどうすればよいですか。入力された値が配列にあるため、explodeを使用するかどうかわかりませんか?つまり、各メールには個別にメッセージを送信する必要があります。
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/>";