1

I have a registration page, after the the registration the form will be generated to the applicant(containing all the form field which was filled by each applicant) which i retrieved form the database, Now i want the generated form to be send as a mail to multiple emails (which was provided by the applicant during the registration. Here is the code for the form Retrieval and its responding i just want this page to be send as a mail to multiple emails like i stated above. Thank you.

    <?php 
$query = "";
include("includes/connect.php");
?>
<?php
if(isset($_GET['name1'])) {
$sql = "SELECT *FROM intern_form WHERE unique_no='".$_GET['name1']."';";
$row = mysql_fetch_array(mysql_query($sql));
}
?>

<p>The Registrar,</p>
<p><?php echo $row['institution']; ?></p>
<p><?php echo $row['institution_address']; ?></p>
<p align="center"><strong>RE: APPLICATION FOR <?php echo    $row['it_duration']; ?> INDUSTRIAL TRAINING:</strong></p>

Dear Sir/Ma,

This is to inform you that the above named student has been accepted for industrial attachment.

I hereby comfirm that we would be in a position to offer Industrial Training in our Directorate(ITeMS).

Please find attached schedule of duty during the attachment.

Thank You.

Yours faithfully,

Signature

Ibrahim
  • 301
  • 2
  • 10

1 Answers1

0
<?php
// send to multiple emails
$to  = 'friend1@example.com' . ', '; // first
$to .= 'friend2@example.com' . ', '; // second and other (with .=)


$subject = "Thanks for register";
$message = '
<html>
    <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Thanks for register</title>
    </head>
    <body>
        <p>Dear Sir/Ma,</p>
        <br>
        <p>This is to inform you that the above named student has been accepted for <p>industrial attachment.</p>
        <br>
        <p>I hereby comfirm that we would be in a position to offer Industrial Training in our Directorate(ITeMS).</p>
        <br>
        <p>Please find attached schedule of duty during the attachment.</p>
        <br>
        <p>Thank You.</p>
        <p>Yours faithfully,</p>
        <p>Signature</p>
    </body>
</html>';


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8 \r\n";


$headers .= "From: yournick <yournick@example.com>\r\n";
$headers .= 'Cc: secondnick@example.com' . "\r\n"; // if you want to send a copy to yourself or anybody

mail($to, $subject, $message, $headers);
?>
Dumkaaa
  • 488
  • 2
  • 9
  • Am very grateful for your response, But the email that will be send to is not static it will be from the database and it will varies, From different applicants, so how do i declare the variable of the emails from the database. – Ibrahim Jun 01 '16 at 11:08
  • @ibrahim tell me how you address are stored in the database? – Dumkaaa Jun 01 '16 at 11:15
  • @ibrahim you need to put emails to the array and then use something like that `$to = implode(', ', $emails_array);` – Dumkaaa Jun 01 '16 at 11:18