<!--Body Starts Here-->
        <div class="container">
    <div class="title">Registration</div>
    <div class="content">
                     <a href="<?php echo SITEURL; ?>admin/index.php?page=parent"><img src="../box/assets/img/unnamed.png" alt="" class="header__img"></a>
                    <form method="post" action="" class="forms">
                        <h2>Add Parent</h2>
                        <?php 
                            if(isset($_SESSION['validation']))
                            {
                                echo $_SESSION['validation'];
                                unset($_SESSION['validation']);
                            }
                            if(isset($_SESSION['add']))
                            {
                                echo $_SESSION['add'];
                                unset($_SESSION['add']);
                            }
                        ?>
                          <div class="user-details">
                            <div class="input-box">
                        <span class="details">First Name</span> 
                        <input type="text" name="first_name" placeholder="First Name" required="true" /> <br />
                        </div>
                        <div class="input-box">
                        <span class="details">Last Name</span>
                        <input type="text" name="last_name" placeholder="Last Name" required="true" /><br />
                        </div>
                        <div class="input-box">
                        <span class="details">Email</span>
                        <input type="email" name="email" placeholder="Email Address" required="true" /><br />
                        </div>
                        <div class="input-box">
                        <span class="details">Username</span>
                        <input type="text" name="username" placeholder="Username" required="true" /><br />
                        </div>
                        <div class="input-box">
                        <span class="details">Password</span>
                        <input type="text" name="password" placeholder="Password" required="true" /><br />
                         </div>
                         <div class="input-box">
                        <span class="details">Contact</span>
                        
                        <input type="tel" name="contact" placeholder="Contact Number" /><br />
                        </div>
                        <div class="input-box">
                         <span class="details">address</span>
                        <input type="text" name="address" placeholder="Address" required="true" /><br />
                        </div>
                          <div class="gender-details">
          <input type="radio" name="gender" id="dot-1">
          <input type="radio" name="gender" id="dot-2">
          <input type="radio" name="gender" id="dot-3">
          <span class="gender-title">Gender</span>
          <div class="category">
            <label for="dot-1">
            <span class="dot one"></span>
            <span class="gender">Male</span>
          </label>
          <label for="dot-2">
            <span class="dot two"></span>
            <span class="gender">Female</span>
          </label>
          
          </div>
        </div>
                        <br><br>
                     <br><br>
                     <br><br>
                     
                        
                       
                        <div class="button"><input type="submit" name="submit" value="Add Parent"/>
                        
                       
                    </form>
                      </div>
            </div>
                    <?php 
                        if(isset($_POST['submit']))
                        {
                            //Getting Values from the form
                            $first_name=$obj->sanitize($conn,$_POST['first_name']);
                            $last_name=$obj->sanitize($conn,$_POST['last_name']);
                            $email=$obj->sanitize($conn,$_POST['email']);
                            $username=$obj->sanitize($conn,$_POST['username']);
                            $password=$obj->sanitize($conn,$_POST['password']);
                            $address=$obj->sanitize($conn,$_POST['address']);
                            $contact=$obj->sanitize($conn,$_POST['contact']);
                            
                            $added_date=date('Y-m-d');
                            
                            //Backend Validation, Checking whether the input fields are empty or not
                            if(($first_name||$last_name||$email||$username||$password)==null)
                            {
                                //SET SSESSION Message
                                $_SESSION['validation']="<div class='error'>First Name or Last Name, or Email or Username or Password is Empty.</div>";
                                header('location:'.SITEURL.'admin/index.php?page=add_parent');
                            }
                            
                            //Addding to the database
                            $tbl_name='tbl_parent';
                            $data="first_name='$first_name',
                                    last_name='$last_name',
                                    email='$email',
                                    username='$username',
                                    password='$password',
                                    contact='$contact',
                                    address='$address',
                                    gender='$gender',
                                  
                                    added_date='$added_date',
                                    updated_date=''";
                            $query=$obj->insert_data($tbl_name,$data);
                            $res=$obj->execute_query($conn,$query);
                            if($res===true)
                            {
                                $_SESSION['add']="<div class='success'>New Parent successfully added.</div>";
                                header('location:'.SITEURL.'admin/index.php?page=parent');
                            }
                            else
                            {
                                $_SESSION['add']="<div class='error'>Failed to add new student. Try again.</div>";
                                header('location:'.SITEURL.'admin/index.php?page=add_parent');
                            }
                        }
                    ?>
                </div>
            </div>
        </div>
        <!--Body Ends Here-->