You are on page 1of 3

1 <?

php
2 # IT IS MAIN
3 defined('BASEPATH') OR exit('No direct script access allowed');
4
5 class Main_Controller extends CI_Controller
6 {
7
8 function __construct(){
9 parent::__construct();
10 $this->check_isvalidated();
11 $this->load->model("Main_Model");
12 }
13
14
15 public function index()
16 {
17 # $this->login();
18
19 }
20
21 public function check_isvalidated()
22 {
23 if(! $this->session->userdata('validated'))
24 {
25 # redirect('login');
26 $this->index();
27 }
28 }
29
30
31
32 public function login()
33 {
34
35 $this->load->view("Login_View");
36 }
37
38
39
40
41 public function Login_Check()
42 {
43 $this->load->library('form_validation');
44 $this->form_validation->set_rules('email', 'Please Enter Email ', 'required');
45 $this->form_validation->set_rules('password', 'Please Enter Password',
'required');
46
47 if($this->input->post('Login') && $this->form_validation->run())
48 #if( $this->form_validation->run())
49 {
50 echo "a";
51
52
53
54 #if($this->input->post('Login'))
55 #{
56 # $this->load->model("Main_Model"); # Do Not REMOVE
57 $this->Main_Model->validate(); # Do Not REMOVE
58 # }
59 # else
60 # {
61 # echo "2";
62 # die();
63 # }
64 }
65 else
66 {
67 //echo "B";
68
69
70 $this->load->view('Login_View');
71 #$this->load->model("Main_Model");
72 #$this->login();
73 #redirect(base_url() . "");
74
75 }
76 }
77
78 public function signin()
79 {
80 $this->load->view('signin');
81 }
82
83 # INSERT DATA Create Account
84 public function signin_validation()
85 {
86
87 $this->load->library('form_validation');
88 $this->form_validation->set_rules('username', 'username', 'required'); # name
# Msg 3 #req|Validataion
89 $this->form_validation->set_rules('email', 'email', 'required');
90 $this->form_validation->set_rules('password', 'Password', 'required');
91 $this->form_validation->set_rules('cpassword', 'Confirm Password',
'required|trim|matches[password]');
92 $this->form_validation->set_message('is_unique', 'email already exists');
93
94
95 if($this->form_validation->run())
96 {
97
98
99 $this->load->model("Main_Model");
100 $data = array(
101 "email"=>$this->input->post("email"),
102 "password"=>$this->input->post("password"),
103 "username"=>$this->input->post("username")
104 );
105
106 if($this->input->post("insert"))
107 {
108 echo "Controll";
109 $this->Main_Model->Create_Account($data);
110 redirect(base_url() . ""); #redirect
111 }
112 }
113 else
114 {
115
116 $this->load->view('signin'); # signin.php
117 }
118 }
119
120
121 public function forget()
122 {
123 $this->load->view('forget');
124 }
125
126 public function otp()
127 {
128 $this->load->view('otp');
129 }
130
131 public function Otp_Check()
132 {
133
134 $this->load->library('form_validation');
135 $this->form_validation->set_rules('otp', 'Please Enter Otp ', 'required');
136
137 if($this->input->post('Send') ) #if( $this->form_validation->run())
138 {
139
140
141 echo "me";
142 die();
143 $this->Main_Model->validate(); # Do Not REMOVE
144
145
146 }
147 }
148
149 public function reset_password()
150 {
151 $this->load->view('reset_password');
152 }
153
154
155 public function logout()
156 {
157 $this->session->sess_destroy();
158 redirect(base_url() . "");
159 }
160
161 }
162

You might also like