function insertPerson($con)
{
    include './db/StudentDAO.php';
    include './db/ParentDAO.php';
    $parent_f_name = $_POST['parentFirstName'];
    $parent_l_name = $_POST['parentLastName'];
    $person_ids = array();
    //insert parent
    $parent_person_id = insertParent($con, $parent_f_name, $parent_l_name);
    $person_ids[] = $parent_person_id;
    //determine number of Students
    $numOfStudets = $_POST['NumOfTix'];
    $studentIndex = 1;
    //insert student(s)
    while ($numOfStudets > 0) {
        $student_person_id = insertStudent($con, $studentIndex);
        $person_ids[] = $student_person_id;
        $studentIndex++;
        $numOfStudets = $numOfStudets - 1;
    }
    return $person_ids;
}
/*                                             License
*   The following license governs the use of CollegeERP in academic and educational environments. Commercial use requires a commercial license from Muhammed Salman Shamsi.
*   ACADEMIC PUBLIC LICENSE
*   Copyright (C) 2014 - 2015  Muhammed Salman Shamsi.
*   FOR DETAILED TERMS AND CONDITION SEE LICENSE.TXT FILE
*   NO WARRANTY
*   BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
*   IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED ON IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*   END OF TERMS AND CONDITIONS
*   [license text: http://www.omnetpp.org/intro/license]   
*   Author: Muhammed Salman Shamsi
*/
require_once 'functions/header.php';
if ($loggedin) {
    if ($_SESSION['grid'] === '3' || $_SESSION['grid'] === '7' || $_SESSION['grid'] === '8') {
        insertStudent();
        ?>
   
<div class="container">
    <div id="left">
        <?php 
        echo '<br><div id="datepicker" style="font-size:0.7em;"></div>';
        echo '<br><br><h4><center>Important Guidelines</h4><br></center>' . $checkmark . ' Please Verify the data before submitting the form<br><br>' . $checkmark . ' Name should be written in following sequence<br>Surname FirstName MiddleName<br><br>' . $checkmark . ' Please provide correct Phone / Mobile Number<br>It will be verified<br><br>' . $checkmark . ' Please provide correct and working E-mail ID<br>It is very important for online communication.<br><br>' . $checkmark . 'Disciplinary action will be taken if information is found to be Incorrect.<br><br>';
        ?>
    </div>
    <div id="right">   
     <form method="post" action="studentregister.php" onsubmit="return validateStudent(this)">
        <center>
         <table cellspacing="10" cellpadding="2" border="0" bgcolor="#00eeee">
           <th colspan="2" align="center">Student Registration</th>
            
function createStudent($rollno, $grno, $firstname, $lastname, $Fname, $Mname, $address, $phone_stu, $phone_father, $phone_mother, $phone_other, $BatchObj, $examyear, $picture, $activeflag, $lasteditedby, $comments, $actid, $ClassObj, $loginflag, $gender, $dateofbirth, $hscno, $cetno, $college, $studentpass, $email, $lastlogin, $parentpass, $dateofadmission, $board10, $agg10, $ms10)
{
    $temp = array();
    // check whetehr student exists in main db
    list($flag, $id) = studentExistsInMainDatabase($phone_stu, $phone_father, $examyear);
    //check whether student exists in current db
    if (!studentExistsInCurrentDatabase($phone_stu, $phone_father, $examyear)) {
        if ($flag) {
            //update classid and add student
            updateStudentClassID($id, getCurrentInstituteID1());
            $mainID = $id;
            $tempobj = insertStudent($mainID, $rollno, $grno, $firstname, $lastname, $Fname, $Mname, $address, $phone_stu, $phone_father, $phone_mother, $phone_other, $BatchObj, $examyear, $picture, $activeflag, $lasteditedby, $comments, $actid, $ClassObj, $loginflag, $gender, $dateofbirth, $hscno, $cetno, $college, $studentpass, $email, $lastlogin, $parentpass, $dateofadmission, $board10, $agg10, $ms10);
            if ($tempobj != NULL) {
                $message = "Student Added successfully : " . $firstname . " " . $lastname;
            } else {
                $message = "Student Addition Failed1 : " . $firstname . " " . $lastname;
                $tempobj = NULL;
            }
        } else {
            //add student in main database and current one
            $mainID = insertStudentInMainDatabase($firstname, $lastname, $phone_stu, $phone_father, $examyear, $activeflag, $actid, $loginflag, $dateofbirth, $studentpass, $lastlogin, $parentpass, getCurrentInstituteID1());
            if ($mainID != NULL) {
                $tempobj = insertStudent($mainID, $rollno, $grno, $firstname, $lastname, $Fname, $Mname, $address, $phone_stu, $phone_father, $phone_mother, $phone_other, $BatchObj, $examyear, $picture, $activeflag, $lasteditedby, $comments, $actid, $ClassObj, $loginflag, $gender, $dateofbirth, $hscno, $cetno, $college, $studentpass, $email, $lastlogin, $parentpass, $dateofadmission, $board10, $agg10, $ms10);
                $message = "Student Added Successfully : " . $firstname . " " . $lastname;
            } else {
                //$message=mysql_error();
                $message = "Student Addition Failed2 : " . $firstname . " " . $lastname;
                $tempobj = NULL;
            }
        }
    } else {
        if ($flag) {
            //update classid
            updateStudentClassID($id, getCurrentInstituteID1());
            //echo $id;
            $tempStu = getStudentByMainID($id, 0);
            //print_r($tempStu);
            if ($tempStu != NULL) {
                $message = "Student Already Exsists  : " . $firstname . " " . $lastname . '.<br />Similar Student Details : Name => ' . $tempStu->getFullName() . '&nbsp; Batch =>' . $tempStu->getBatchObj()->getBestDisplay();
            } else {
                $message = "Student Already Exsists Harsh  : " . $firstname . " " . $lastname;
            }
            //updateStudentBatchID($tempStu->getID(),27,3);
            $tempobj = NULL;
        } else {
            //add student in main database
            //since student exists in current db n nt in main db, there must be sum error
            $message = "Contact System Administrator : " . $firstname . " " . $lastname;
            $tempobj = NULL;
        }
    }
    array_push($temp, $message);
    array_push($temp, $tempobj);
    return $temp;
}
            $src = imagecreatefromjpeg($fileTmpLoc);
        } elseif ($check[2] == IMAGETYPE_PNG) {
            $src = imagecreatefrompng($fileTmpLoc);
        } else {
            $src = imagecreatefromgif($fileTmpLoc);
        }
        list($width, $height) = getimagesize($fileTmpLoc);
        $newwidth1 = 17;
        $newheight1 = 18;
        $tmp1 = imagecreatetruecolor($newwidth1, $newheight1);
        imagecopyresampled($tmp1, $src, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height);
        if (!move_uploaded_file($fileTmpLoc, $file_path)) {
            echo '<script language="javascript">
                  alert("ERROR: File not uploaded. Try again !!");
                  window.location="' . SERVER . '/profile";
              </script>';
            /** Remove the uploaded file from the PHP temp folder */
            unlink($fileTmpLoc);
            return;
        }
        $newIco = uniqid('') . md5($filename) . '_s.' . $fileext;
        $icoImage = $target_dir . "ico/" . $newIco;
        imagejpeg($tmp1, $icoImage, 100);
        imagedestroy($tmp1);
        insertStudent($ID, $name, $cgpa, $phone, $email, $dept, $image, $gender, $date, $newIco, $fileContents);
    }
}
echo '<script language="javascript">
          alert("Successfully Added !!");
          window.location="' . SERVER . '";
      </script>';