奨学金の申請を申請者に通知するために、2 つの異なるメールを送信したいと思います。ユーザーがコンボボックスから [承認] を選択すると、システムは申請者の電子メール アドレスに電子メール通知を自動的に送信します。それ以外の場合は、取消通知を送信します。これが私がこれまでに試したことです:
<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<strong>Applicant ID:</strong> <?php echo $id; ?><br />
<strong>Applicant name: </strong>
<input type="text" name="username" readonly value="<?php echo $lastname. "," . $firstname. " " .substr($middlename, 0,1); ?>"/><br/>
<strong>Username: </strong><input type="text" readonly name="username" value="<?php echo $username; ?>" /> <br />
<strong>Password: </strong><input type="text" readonly name="password" value="<?php echo $password; ?>" /> <br />
<strong>Manage Application: </strong><select name="status">
<?php
$selection = array(
0 => "Pending",
1 => "Approve",
2 => "Revoke" );
foreach($selection as $key => $value)
{
echo '<option value="' . $key . '"';
if ($status == $key)
echo ' selected="selected"';
echo '>' . $value . '</option>';
echo ' <br />';
}
?>
</select>
<br />
<button type="submit" name="submit" value="Submit"><img src="../../images/login.png" />Update</button>
<?php
if(isset($_POST['submit']))
{
if($selection == 1){
$to = '.$email.';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
if (mail($to, $subject, $message, $headers)) {
echo("<p>Congrats!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}
else if($selection == 2)
{
$to = $email;
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
if (mail($to, $subject, $message, $headers)) {
echo("<p>Sorry your application is revoked!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}
} // end of if button pressed
?>
<a href="../index.php"><button type="button"><img src="../../images/back.png"/>Back</button></a>
</div>
</form>
しかし、メールを確認したところ、送信されていませんでした。そして、これは正しいですか?
$to = $email;
行から $email を取得しました['EmailAddress'];
私が欠けているものを理解するのを手伝ってください。ありがとう。