You are on page 1of 3

<?

php class Index extends MY_Controller { function __construct() { parent::__construct(); } function index() { $this->load->helper(array('form', 'url', 'phpmailer')); $this->load->library('form_validation'); // $this->form_validation->set_rules('username', 'Username', 'required xs s_clean'); $this->form_validation->set_rules('password', 'Password', 'required xss_ clean'); $this->form_validation->set_rules('fullname', 'Fullname', 'required xss_ clean'); $this->form_validation->set_rules('email', 'Email', 'required xss_clean' ); $this->form_validation->set_rules('type', 'Type', 'required xss_clean'); if ($this->input->post("submit")) { $token_number = base64_encode(date('Y-m-d H:i:s', strtotime("now"))); $fullname = $this->input->post('fullname'); $userRegData = array( 'password' => $this->input->post("password"), 'full_name' => $this->input->post("fullname"), 'email' => $this->input->post("email"), 'type' => $this->input->post("type"), 'token'=> $token_number, 'status'=> 0 ); if ($this->form_validation->run() == TRUE) { $this->db->insert('users', $userRegData); $subject = 'Subject'; $mail_data['email'] = $this->input->post("email"); $mail_data['password'] = $this->input->post("password"); $mail_data['link'] = "<a href='http://dev.lawschool.co m/index/check_token?token=$token_number'>$token_number</a>"; // $mail_data = 'This is an activation email' . "<br/>"; // $link = "<a href='http://dev.lawschool.com/index/check_token?tok en=$token_number'>$token_number</a>"; // $email_data .= $link; $email_data = $this->load->view('templates/create_accou nt', $mail_data, true); if (send_email('manish.kumar@calipus.com', $this->config->item('se ndMailFromEmail'), $this->config->item('sendMailFromName'), $subject, $email_dat a)){ $this->session->set_flashdata('notice', 'An email has been sent to you for confirmation.'); redirect('/index'); } else { $this->session->set_flashdata('error', 'Please Try Again .'); redirect('/index'); } } } $this->render('layout'); } function check_token() {

$token = $this->input->get('token'); $this->load->helper(array('form', 'url')); $this->db->where('token', $token); $token_query = $this->db->get('users'); if ($token_query->num_rows() > 0) { $usertokenDetails = $token_query->row_array(); $status = array( 'status' => '1' ); $this->db->where('token', $token); $this->db->update('users', $status); redirect('/index'); } else { echo "Yor are not valid user."; } $this->render('layout'); } function login(){ $this->load->helper(array('form', 'url')); $userLogin = array( 'email' => $this->input->post("username"), // 'password' => md5($this->input->post("password")), 'password' => $this->input->post("password"), ); $login_query = $this->db->get_where('users', $userLogin); if ($login_query->num_rows() > 0) { $userDetails = $login_query->row_array(); // p($userDetails); $sessionData = array( 'login_id' => $userDetails['id'], 'username' => $userDetails['full_name'], 'type' => $userDetails['type'], ); $this->session->set_userdata($sessionData); redirect('/index/homepage'); } else { $this->session->set_flashdata('error', 'Username or Password is in correct.'); redirect('/index1/login'); } } function homepage(){ $this->load->helper(array('form', 'url')); $this->render('home'); } function edit_law_profile(){ $login_id = $this->session->userdata['login_id']; $this->load->model('user_model'); $data = $this->user_model->getEditProfileData(); $edit_profile_data['profile_result'] = $data; $this->data = $edit_profile_data; $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->form_validation->set_rules('full_name', 'Full Name', 'required xs s_clean'); $this->form_validation->set_rules('email', 'Email', 'required xss_clean' );

$this->form_validation->set_rules('phone_number', 'Phone Number', 'requi red xss_clean'); $this->form_validation->set_rules('mobile', 'Mobile', 'required xss_clea n'); $this->form_validation->set_rules('state_id', 'state_id', 'required xss_ clean'); $this->form_validation->set_rules('school', 'School', 'required xss_clea n'); $this->form_validation->set_rules('department', 'Department', 'required xss_clean'); if ($this->input->post("submit")) { $userInfo = array( 'full_name' => $this->input->post("full_name"), 'email' => $this->input->post("email"), 'phone_number' => $this->input->post("phone_number"), 'mobile' => $this->input->post("mobile"), 'state_id' => $this->input->post("state_id"), 'school' => $this->input->post("school"), 'department' => $this->input->post("department") ); if ($this->form_validation->run() == TRUE) { $this->db->where('id', $login_id); $this->db->update('users', $userInfo); $this->session->set_flashdata('notice', 'You have been updated Profi le successfully.'); } redirect('/user/editprofile'); } $this->render('home'); } } ?>

You might also like