<?php
ob_start();

defined('BASEPATH') OR exit('No direct script access allowed');
 

class Userhome extends CI_Controller
{
  function __construct() {

        parent::__construct();

        $this->load->database();
		$this->load->model('usermodel','',TRUE);
				 $this->load->model('studentprofilemodel','',TRUE);

		$this->load->model("usermodel", "login",TRUE);
        if(!empty($_SESSION['id']))
            redirect('admin');


    }

    public function studenthome() {
	$session_data = $this->session->userdata('logged_in');

     $data['surname'] = $session_data['surname'];
 	$data['id'] = $session_data['id'];
	
	 	$this->load->view("template/headerpage");


		 $this->load->view('studentpage', $data);
		$this->load->view("template/footerpage");
     
    }
 
 
 
   public function studentbio() {
	$session_data = $this->session->userdata('logged_in');

     $data['surname'] = $session_data['surname'];
 	$data['id'] = $session_data['id'];
 		$data['firstname'] = $session_data['firstname'];
 			$data['secondname'] = $session_data['secondname'];
 				$data['surname'] = $session_data['surname'];
 				$data['contact'] = $session_data['contact'];

 	$surname= $data['surname'] ;
	$id= $data['id'] ;
	 $biodata['bio'] = $this->usermodel->populatebiodata($surname);
	 	$this->load->view("template/headerpage");
	

		 $this->load->view('userdata/biodata1', $data);
		$this->load->view("template/footerpage");
     
    }
	
	
	

  
	
 
              function uploadmembers($data)
{
// Query to insert data in database
  $regno = $data['regno'];
   $this -> db -> select("* from studentapplication where regno='$regno'");

   $query = $this -> db -> get();
  if($query -> num_rows() == 0)

   {

    $this->db->insert('studentapplication', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }else{
		     return false;
  
	  }

   }

  


}

 
 
 
     public function studentpassword() {
	$session_data = $this->session->userdata('logged_in');

     $data['surname'] = $session_data['surname'];
 	$data['id'] = $session_data['id'];
	
	 	$this->load->view("template/headerpagemin");
		

		$this->load->view('userdata/resetpassword', $data);
		$this->load->view("template/footerpage");
     
    }
	

    public function logout() {
        $data = ['id', 'surname'];
        $this->session->unset_userdata('logged_in');
		session_destroy();

  		 redirect('login', 'refresh');
       
    }
}
  ?>