-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStudent.php
103 lines (89 loc) · 2.44 KB
/
Student.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class Student extends CI_controller
{
function __construct()
{
parent::__construct();
$this->load->model('student_model');
}
public function index()
{
$data['students'] = $this->student_model->getstudent();
$this->load->view('student_details' , $data);
}
public function addstudent()
{
$this->load->view('add_student');
}
public function addstudentdata()
{
if($_POST)
{
$data = array('name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'phoneno' => $this->input->post('contact'));
if($this->student_model->insertstudent($data))
{
$this->session->set_flashdata('msg', '<div class="alert alert-success text-center">Student details added successfully.</div>');
redirect(base_url().'student/addstudent', 'refresh');
}
else
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Please Try Again...</div>');
redirect(base_url().'student/addstudent', 'refresh');
}
}
else
{
redirect(base_url());
}
}
public function editstudent($id)
{
if(!empty($id))
{
$data['students'] = $this->student_model->get_details($id);
// print_r($data);
$this->load->view('show_students' , $data);
}
else
{
redirect(base_url());
}
}
public function updatedetails($id)
{
if ($_POST)
{
$data = array('name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'phoneno' => $this->input->post('contact'));
if($this->student_model->update_details($data, $id) > 0)
{
$this->session->set_flashdata('msg', '<div class="alert alert-success text-center">Student details updated successfully.</div>');
redirect(base_url().'student/editstudent/'.$id, 'refresh');
}
else
{
$this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Please Try Again...</div>');
redirect(base_url().'student/editstudent/'.$id, 'refresh');
}
}
else
{
redirect(base_url());
}
}
public function deletedetails($id)
{
$this->student_model->delete_details($id);
$this->session->set_flashdata('msg', '<div class="alert alert-success text-center">Details deleted successfully!</div>');
redirect(base_url());
}
}