
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include 'connection.php';

// Email settings
$admin_email = "scholarship@communitybuildersforafrica.org"; // Replace with your email
$admin_email_password = "vo&[^]hArUHv"; // Replace with your email password
$smtp_host = "mail.communitybuildersforafrica.org"; // Replace with your SMTP host
$smtp_port = 465; // Adjust as per your SMTP settings
$email = "info@communitybuildersforafrica.org" ;

if (isset($_POST['submit'])) {
    
    
    // Sponsor Information
    $sponsorName = $_POST["sponsor_name"];
    $sponsorPhone = $_POST["sponsor_phone"];
    

    // Coordinator Information
    $coordinatorName = $_POST["coordinator_name"];
    $coordinatorPhone = $_POST["coordinator_phone"];
    

    // School Information
    $schoolName = $_POST["school_name"];
    $state = $_POST["state"];
    $lga = $_POST["lga"];
    $location = $_POST["location"];

    // Principal Information
    $principalName = $_POST["principal_name"];
    $principalPhone = $_POST["principal_phone"];
   

    // Applicant 1 Information
    $applicant1Name = $_POST["applicant1_name"];
    $applicant1Phone = $_POST["applicant1_phone"];
   
    $applicant1ParentName = $_POST["applicant1_parent_name"];
    $applicant1ParentPhone = $_POST["applicant1_parent_phone"];
    
  
//files upload1
$sponsorSignature = "uploads/";  
$sponsorSignature = $sponsorSignature.basename( $_FILES['sponsor_signature']['name']);   
  
move_uploaded_file($_FILES['sponsor_signature']['tmp_name'], $sponsorSignature);

//files upload2
$coordinatorSignature = "uploads/";  
$coordinatorSignature = $coordinatorSignature.basename( $_FILES['coordinator_signature']['name']);   
  
move_uploaded_file($_FILES['coordinator_signature']['tmp_name'], $coordinatorSignature);

//files upload3
$principalSignature = "uploads/";  
$principalSignature = $principalSignature.basename( $_FILES['principal_signature']['name']);   
  
move_uploaded_file($_FILES['principal_signature']['tmp_name'], $principalSignature);


//files upload4
$applicant1Signature = "uploads/";  
$applicant1Signature = $applicant1Signature.basename( $_FILES['applicant1_signature']['name']);   
  
move_uploaded_file($_FILES['applicant1_signature']['tmp_name'], $applicant1Signature);

//files upload5
$applicant1ParentSignature = "uploads/";  
$applicant1ParentSignature = $applicant1ParentSignature.basename( $_FILES['applicant1_parent_signature']['name']);   
  
move_uploaded_file($_FILES['applicant1_parent_signature']['tmp_name'], $applicant1ParentSignature);





    // Insert data into the database
    $sql= "INSERT INTO `form`(`sponsorName`, `sponsorPhone`, `coordinatorName`, `coordinatorPhone`, `schoolName`, `state`, `lga`, `location`, `principalName`, `principalPhone`, `applicantName`, `applicantPhone`, `applicantParentName`, `applicantParentPhone`,  `sponsorSig`, `cordinatorSig`, `principalSig`, `applicantSig`, `applicantParSig`) VALUES ('$sponsorName','$sponsorPhone','$coordinatorName','$coordinatorPhone','$schoolName','$state','$lga','$location','$principalName','$principalPhone','$applicant1Name','$applicant1Phone','$applicant1ParentName','$applicant1ParentPhone', '$sponsorSignature','$coordinatorSignature','$principalSignature','$applicant1Signature','$applicant1ParentSignature' )";

$rs = mysqli_query($conn, $sql);
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

if($rs)
    
    {
        
        $mail = $mail = new PHPMailer(true);
        $mail->isSMTP();
        $mail->Host = $smtp_host;
        $mail->SMTPAuth = true;
        $mail->Username = $admin_email;
        $mail->Password = $admin_email_password;
        $mail->SMTPSecure = 'tls';         
        $mail->Port       = 587;   
        $mail->setFrom($admin_email, 'Signup Form');
        $mail->addAddress($email);
        $mail->addCC($admin_email);
        $mail->Subject = "Applicants Signup Details";
        $mail->Body = "$applicant1Name information submitted successfully.\n Here are the details:\n" .
            "Sponsor name: $sponsorName\nSponsor Phone: $sponsorPhone\nCoordinator Name: $coordinatorName\nCoordinator Phone: $coordinatorPhone\nSchool Name Name: $schoolName\nState: $state\nLocal Government: $lga\n" .
            "Location: $location\nPrincipal Name: $principalName\nPrincipal Phone: $principalPhone\nApplicant Name: $applicant1Name\nApplicant Phone: $applicant1Phone\nApplicant Parent: $applicant1ParentName\n" .
            "Applicant Parent Phone: $applicant1ParentPhone\n";

        if ($mail->send()) {

        echo '<script>alert("Information submitted successfully.")</script>';
        echo '<script> window.location.href = "../waec-schorlarship.php";</script>';

        } else {
            echo '<script>alert("Information submitted successfully, but failed to send email")</script>';
        }
        
    } else {
        echo '<script>alert("Something Went Wrong. Please try again")</script>';
    }
}

?>




<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link rel="shortcut icon" href="favicon.png" type="image/x-icon">
    <link rel="icon" href="favicon.png" type="image/x-icon">
    <link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
    <title>CBA WAEC FEES SCHOLARSHIP AWARD</title>
</head>

<body>
    <div class="container">
        <div style="text-align: center;">
           <a href="index.php"> <img src="logo.png" /></a>
        </div>
         <div style="text-align: center;">
             <a href="../uploads/INSTRUCTIONS TO COMPLETE CBA WAEC ASSISTANCE PROJECT.pdf">FORM INSTRUCTION</a> <a href="../uploads/WAEC Assistance Disbursment Form 2023-24 Updated.pdf">DISBURSEMENT FORM</a> <a href="../uploads/WAEC FEES ASSISTANCE AWARD 2023-24.pdf">FEES ASSISTANCE</a>
    
          </div>
          <br>
              <header>CBA WAEC FEES SCHOLARSHIP AWARD</header>
        <form  method="post" enctype="multipart/form-data">
            <!-- Add enctype="multipart/form-data" for file uploads -->
            <div class="form first">
                <div class="details personal">
                    <span class="title">A member of Community Builders for Africa has nominated this school for the WAEC Scholarship Award of the organization for eligible WAEC candidates of the school in the current WAEC/NECO enrollment year. Please fill the form below to complete the scholarship award process.</span>
                    <br>
                    <div class="details ID">
                        <span class="title">Application Form</span>
                        <div class="fields">
                            <div class="input-field"><label>Name of Sponsor Member</label><input type="text" name="sponsor_name"
                                    placeholder="Enter Name of Sponsor Member" required></div>
                            <div class="input-field"><label>Phone Number</label><input type="number"
                                    name="sponsor_phone" placeholder="Enter phone number"></div>
                            <div class="input-field"><label>Signature: <a target="blank" rel="nofollow" href="../sign" >click here to sign</a></label><input type="file" name="sponsor_signature"
                                    placeholder="Upload your Signature"></div>
                            <div class="input-field"><label>Name of Co-ordinator</label><input type="text"
                                    name="coordinator_name" placeholder="Enter name of co-ordinator" required></div>
                            <div class="input-field"><label>Phone Number</label><input type="number"
                                    name="coordinator_phone" placeholder="Enter Phone Number" required></div>
                            <div class="input-field"><label>Signature: <a target="blank" rel="nofollow" href="../sign" >click here to sign</a></label><input type="file"
                                    name="coordinator_signature" placeholder="Signature" required></div>
                                    
                        </div>
                    </div>
                    <p>School Information</p>
                    <div class="fields">
                        <div class="input-field"><label>Name of School</label><input type="text" name="school_name"
                                placeholder="Enter school name" required></div>
                        <div class="input-field"><label>State</label>
                            <select onchange="toggleLGA(this);" name="state" id="state" class="form-control">
							<option value="" selected="selected">- Select State-</option>
							<option value="Abia">Abia</option>
							<option value="Adamawa">Adamawa</option>
							<option value="AkwaIbom">AkwaIbom</option>
							<option value="Anambra">Anambra</option>
							<option value="Bauchi">Bauchi</option>
							<option value="Bayelsa">Bayelsa</option>
							<option value="Benue">Benue</option>
							<option value="Borno">Borno</option>
							<option value="Cross River">Cross River</option>
							<option value="Delta">Delta</option>
							<option value="Ebonyi">Ebonyi</option>
							<option value="Edo">Edo</option>
							<option value="Ekiti">Ekiti</option>
							<option value="Enugu">Enugu</option>
							<option value="FCT">FCT</option>
							<option value="Gombe">Gombe</option>
							<option value="Imo">Imo</option>
							<option value="Jigawa">Jigawa</option>
							<option value="Kaduna">Kaduna</option>
							<option value="Kano">Kano</option>
							<option value="Katsina">Katsina</option>
							<option value="Kebbi">Kebbi</option>
							<option value="Kogi">Kogi</option>
							<option value="Kwara">Kwara</option>
							<option value="Lagos">Lagos</option>
							<option value="Nasarawa">Nasarawa</option>
							<option value="Niger">Niger</option>
							<option value="Ogun">Ogun</option>
							<option value="Ondo">Ondo</option>
							<option value="Osun">Osun</option>
							<option value="Oyo">Oyo</option>
							<option value="Plateau">Plateau</option>
							<option value="Rivers">Rivers</option>
							<option value="Sokoto">Sokoto</option>
							<option value="Taraba">Taraba</option>
							<option value="Yobe">Yobe</option>
							<option value="Zamfara">Zamafara</option>
						</select></div>
                        <div class="input-field"><label>Local Government</label>
                            <select name="lga" id="lga" class="form-control select-lga" required>
						</select></div>
                        <div class="input-field"><label>City/Location</label><input type="text" name="location"
                                placeholder="Enter school location" required></div>
                    </div>
                </div>
               
                   
                    <div class="fields">
                        <div class="input-field"><label>Name of Principal</label><input type="text" name="principal_name"
                                placeholder="Enter name of Principal" required></div>
                        <div class="input-field"><label>Phone Number</label><input type="number"
                                name="principal_phone" placeholder="Enter Phone number" required></div>
                        <div class="input-field"><label>Signature: <a target="blank" rel="nofollow" href="../sign" >click here to sign</a></label><input type="file" name="principal_signature"
                                placeholder="Upload your Signature" required></div>
                    
                    
                
            
           
                
                    
                        <div class="input-field"><label>Name of Applicant</label><input type="text" name="applicant1_name"
                                placeholder="Enter name of applicant" required></div>
                        <div class="input-field"><label>Phone Number</label><input type="number" name="applicant1_phone"
                                placeholder="Phone Number" required></div>
                        <div class="input-field"><label>Signature</label><input type="file" name="applicant1_signature"
                                placeholder="Signature" required></div>
                        <div class="input-field"><label>Name of Parent</label><input type="text"
                                name="applicant1_parent_name" placeholder="Enter name of parent" required></div>
                        <div class="input-field"><label>Phone Number</label><input type="number"
                                name="applicant1_parent_phone" placeholder="Enter Phone Number" required></div>
                        <div class="input-field"><label>Signature: <a target="blank" rel="nofollow" href="../sign" >click here to sign</a></label><input type="file"
                                name="applicant1_parent_signature" placeholder="Signature" required></div>
                    </div>
             
                
               
                <div class="buttons">
                    
                    <button type="submit" name="submit" class="submit"><span class="btnText">Submit</span>
                    <i class="uil uil-navigator"></i></button>
                </div>
            </div>
        </form>
    </div>
    <script src="js/lga.min.js"></script>
    <script src="script.js"></script>
</body>

</html>
