<?php

require 'Mail/phpmailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

try{
    
    // Step 2: Collect form data
    $student_name = $_POST['student_name'];
    $class = $_POST['class'];
    $parent_name = $_POST['parent_name'];
    $address = $_POST['address'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    
    $mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';

$mail->Username = 'garimas876s@gmail.com';

$mail->Password = 'ryib mmwa mzls pmts';
        $mail->setFrom('garimas876s@gmail.com', 'SKS World School Greater Noida'); 

        
        $mail->addAddress('garimas876s@gmail.com', 'SKS World School Greater Noida'); 
     
       

        $mail->addBCC('sksworldschool2025@gmail.com ', 'SKS World School Greater Noida');

        $mail->addBCC('sksnoidamathura@gmail.com', 'SKS World School Greater Noida');
        
        
   // Content
    $mail->isHTML(true);                                          // Set email format to HTML
    $mail->Subject = 'New Application Form Submission';           // Subject of the email

    // Build the message body (could be dynamic as per your form data)
    $message = "
    <html>
    <head>
    <title>New Application Submission</title>
    </head>
    <body>
    <h2>New Application Form</h2>
    <p><strong>Student Name:</strong> $student_name</p>
    <p><strong>Class Applying For:</strong> $class</p>
    <p><strong>Parent/Guardian Name:</strong> $parent_name</p>
    <p><strong>Address:</strong> $address</p>
    <p><strong>Phone Number:</strong> $phone</p>
    <p><strong>Email Address:</strong> $email</p>
    </body>
    </html>
    ";
    $mail->Body = $message;

    // Send email
    $mail->send();
    echo 'Application submitted successfully!';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>