Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Profil extends Controller {
- function index()
- {
- $this->load->model('profil_model');
- $data['query'] = $this->profil_model->vis_profil($this->uri->segment(3));
- $data['content'] = 'profil_view';
- $this->load->view('includes/template', $data);
- }
- function indstillinger()
- {
- $this->access->protect();
- $this->load->model('profil_model');
- $data['query'] = $this->profil_model->indstillinger($this->uri->segment(3));
- $data['content'] = 'indstillinger_view';
- $this->load->view('includes/template', $data);
- }
- function ret_profil()
- {
- $username = $this->session->userdata('username');
- if ($this->_submit_ret() === false) {
- redirect('profil/indstillinger/'.$username);
- return;
- //echo "validate fejl";
- } else {
- $new_member_insert_data = array(
- 'firstname' => $this->input->post('fornavn'),
- 'lastname' => $this->input->post('efternavn'),
- 'email' => $this->input->post('email'),
- 'hood' => $this->input->post('hood'),
- 'city' => $this->input->post('city'),
- 'freetext' => $this->input->post('fritekst'),
- 'sex' => $this->input->post('kon'),
- 'birthday' => $this->input->post('birthday'),
- 'birthmonth' => $this->input->post('birthmonth'),
- 'birthyear' => $this->input->post('birthyear')
- );
- $this->db->where('username', $username);
- $this->db->update('users', $new_member_insert_data);
- //echo $birthDay;
- //echo $alder;
- //$data['besked'] = 'Din information blev opdateret';
- //$data['content'] = 'indstillinger_view';
- //$this->load->view('includes/template', $data);
- redirect('profil/indstillinger/'.$username);
- }
- }
- // function til ret profil indstillinger
- function _submit_ret()
- {
- $this->form_validation->set_rules('fornavn', 'Fornavn',
- 'required|alpha_numeric|min_length[2]|max_length[30]');
- $this->form_validation->set_rules('efternavn', 'Efternavn',
- 'required|alpha_numeric|min_length[2]|max_length[70]');
- $this->form_validation->set_rules('hood', 'Hood',
- 'required|numeric|min_length[4]|max_length[4]');
- $this->form_validation->set_rules('city', 'City',
- 'required|min_length[4]|max_length[90]');
- $this->form_validation->set_rules('email', 'E-mail',
- 'required|valid_email');
- return $this->form_validation->run();
- }
- ## Billed upload til ret profil ##
- function uploadImg()
- {
- $this->load->model('profil_model');
- if($this->input->post('upload'))
- {
- $this->profil_model->addProfileImg();
- redirect('profil/indstillinger/'.$this->session->userdata('username'));
- }
- }
- function editPassword()
- {
- $this->form_validation->set_rules('password', 'Password',
- 'required|min_length[6]');
- $this->form_validation->set_rules('newPassword', 'newPassword',
- 'required|min_length[6]');
- $this->form_validation->set_rules('matchPassword', 'matchPassword',
- 'required|min_length[6]|matches[newPassword]');
- if($this->form_validation->run() === false)
- {
- //$this->load->view('indstillinger_view');
- //echo "vis fejl";
- } else {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $this->load->model('profil_model');
- $query = $this->profil_model->passwordCheck($password, $username);
- if($query === true)
- {
- //henter det nye password
- $newPassword = $this->input->post('newPassword');
- $this->db->update('password', $newPassword);
- $this->db->where('username', $username);
- } else {
- echo "forkert";
- }
- }
- }
- function logud()
- {
- $this->session->sess_destroy();
- redirect('/');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement