<?php include("db.php"); ?>
                <h3>Hostel Accommodation Form</h3>
                <hr/>
                <div class="container">
					<div class="row">
                    <form method="post" action="index.php?env=register-hostel" enctype="multipart/form-data">
                    <p style="font-size:13px;"><b>STUDENT PARTICULARS</b></p>
                   <div class="row form-group">
                       <div class="col-md-6">
                            <input type="text" name="surname" class="form-control" placeholder="Surname" required>
                       </div>
                       <div class="col-md-6">
                            <input type="text" name="othernames" class="form-control" placeholder="Other Names" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                            <select name="department" class="form-control" required>
                                <option value="Select-Program">Select Program</option>
                                <option value="ND-Computer-Science">ND Computer Science</option>
                                <option value="ND-Computer-Engineering">ND Computer Engineering</option>
                                <option value="ND-Business-Administration">ND Business Administration</option>
                                <option value="ND-Electrical/Electronics-Engineering">ND Electrical/Electronics Engineering</option>
                            </select>
                       </div>
                       <div class="col-md-6">
                            <input type="date" name="dob" class="form-control" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="residential_address" class="form-control" placeholder="Residential Address" required>
                       </div>
                       <div class="col-md-6">
                             <input type="text" name="postal_address" class="form-control" placeholder="Postal Address" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="place_birth" class="form-control" placeholder="Place of Birth" required>
                       </div>
                       <div class="col-md-6">
                             <input type="text" name="state_origin" class="form-control" placeholder="State of Origin" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="LGA" class="form-control" placeholder="L.G.A" required>
                       </div>
                       <div class="col-md-6">
                             <input type="text" name="blood_group" class="form-control" placeholder="Blood Group" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="illness" class="form-control" placeholder="State known illness (if any)" required>
                       </div>
                       <div class="col-md-6">
                             <input type="tel" name="phone" class="form-control" placeholder="Phone Number" required>
                       </div>
                   </div>
                   
                   <div class="row form-group">
                       <div class="col-md-12">
                             <input type="email" name="email" class="form-control" placeholder="Email" required>
                             <p><b>HOSTEL ACCOMMODATION FEES: Only students who indicate and have made payments 
                                will be allocated bed spaces.</b></p>
                       </div>
                      
                   </div>
                   
                     <p style="font-size:13px;"><b>PARTICULARS OF PARENT/GUARDIAN</b></p>
                     <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="fname" class="form-control" placeholder="Name of Parents/Guardian: Father" required>
                       </div>
                       <div class="col-md-6">
                             <input type="tel" name="mother" class="form-control" placeholder="Mother" required>
                       </div>
                   </div> 
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="aaddress" class="form-control" placeholder="Address" required>
                       </div>
                       <div class="col-md-6">
                             <input type="tel" name="nameguardian" class="form-control" placeholder="Name of Guardian" required>
                       </div>
                   </div> 
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="occfather" class="form-control" placeholder="Occupation of Father" required>
                       </div>
                       <div class="col-md-6">
                             <input type="tel" name="occmother" class="form-control" placeholder="Occupation of Mother" required>
                       </div>
                   </div> 
                   
                   <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="occguardian" class="form-control" placeholder="Occupation of Guardian" required>
                       </div>
                       <div class="col-md-6">
                             <input type="tel" name="phoneall" class="form-control" placeholder="Phone Number: Father, Mother, Guardian" required>
                       </div>
                   </div> 
                   
                    <p style="font-size:13px;"><b>Contact Address</b></p>
                     <div class="row form-group">
                       <div class="col-md-6">
                             <input type="text" name="fathername" class="form-control" placeholder="Father" required>
                       </div>
                       <div class="col-md-6">
                            <input type="text" name="mothername" class="form-control" placeholder="Mother" required>
                       </div>
                   </div> 
                   
                   <div class="row form-group">
                       <div class="col-md-12">
                              <input type="text" name="guardian" class="form-control" placeholder="Guardian" required>
                       </div>
                   </div>

                    <!--<input type="submit" name="submit" clas="btn btn-primary btn-block" value="Submit">-->
                    <button type="submit" name="hostelsubmit" class="btn btn-success btn-block">Submit</button>
                </form>
                    
					</div>
				</div>

                <div class="row" style="margin-top:50px;">
                        <div class="col-md-6">
                            <a href="index.php?env=hostel" style="color:#ffffff;text-decoration:none;"> 
                                <button type="button" class="btn btn-primary btn-block"><i class="fa fa-arrow-left"></i> Go back</button>
                            </a>
                        </div>
                        <div class="col-md-6">
                        
                        </div>
                    </div>


<?php

if(isset($_POST['hostelsubmit'])){
    $surname = mysqli_real_escape_string($db, $_POST['surname']);
    $othernames = mysqli_real_escape_string($db, $_POST['othernames']);
    $department = mysqli_real_escape_string($db, $_POST['department']);
    
    $dob = mysqli_real_escape_string($db, $_POST['dob']);
    $residential_address = mysqli_real_escape_string($db, $_POST['residential_address']);
    
    $postal_address = mysqli_real_escape_string($db, $_POST['postal_address']);
    $place_birth = mysqli_real_escape_string($db, $_POST['place_birth']);
    $state_origin = mysqli_real_escape_string($db, $_POST['state_origin']);
    
    $LGA = mysqli_real_escape_string($db, $_POST['LGA']);
    $blood_group = mysqli_real_escape_string($db, $_POST['blood_group']);
    $illness = mysqli_real_escape_string($db, $_POST['illness']);
    
    $phone = mysqli_real_escape_string($db, $_POST['phone']);
    $email = mysqli_real_escape_string($db, $_POST['email']);
    
     $fname = mysqli_real_escape_string($db, $_POST['fname']);
    $mother = mysqli_real_escape_string($db, $_POST['mother']);
     $aaddress = mysqli_real_escape_string($db, $_POST['aaddress']);
    $nameguardian = mysqli_real_escape_string($db, $_POST['nameguardian']);
    
     $occfather = mysqli_real_escape_string($db, $_POST['occfather']);
    $occmother = mysqli_real_escape_string($db, $_POST['occmother']);
    
    $occguardian = mysqli_real_escape_string($db, $_POST['occguardian']);
    $phoneall = mysqli_real_escape_string($db, $_POST['phoneall']);
     $fathername = mysqli_real_escape_string($db, $_POST['fathername']);
    $mothername = mysqli_real_escape_string($db, $_POST['mothername']);
    
     $guardian = mysqli_real_escape_string($db, $_POST['guardian']);
     
     $query = "INSERT INTO hostel_table(surname, othernames, department, dob, residential_address, postal_address, place_birth, state_origin, LGA, blood_group, illness, phone, email, fname, mother, aaddress, nameguardian, occfather, occmother, occguardian, phoneall, fathername, mothername, guardian) 
VALUES('$surname', '$othernames', '$department', '$dob', '$residential_address', '$postal_address', '$place_birth', '$state_origin', '$LGA', '$blood_group', '$illness', '$phone', '$email', '$fname', '$mother', '$aaddress', '$nameguardian', '$occfather', '$occmother', '$occguardian', '$phoneall', '$fathername', '$mothername', '$guardian')";
       if (mysqli_query($db, $query)) {
        echo "<script>alert('Hostel Application Successfully')</script>";  
      
   } else {
      echo "<script>alert('Hostel Application Not Successfully')</script>";  
   }

   
}

?>