私はすべてのプロフィールをユーザーとして編集できるという問題があります。しかし、私は自分のプロフィールを編集することしかできません。多分あなたは私を助けることができます。コードは、私がCodeigniterユーザーとして自分自身のプロフィールを編集
ドメイン/メンバー/ユーザー/管理/ 1
ように私のプロフィールを編集したいが、私は、編集/メンバー/ユーザー/余りに/ 2を管理することができれば作業や、問題のthatsています。
コントローラUsers.php
public function manage($id = NULL) {
if($this->session->userdata('type') == 'user') {
$data = array();
if ($id) {
$this->{$this->model}->{$this->_primary_key} = $id;
$data['item'] = $this->{$this->model}->get();
if (!$data['item'])
show_404();
} else {
$data['item'] = new Std();
}
$this->load->library("form_validation");
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->{$this->model}->custom_select = 'users.*, teams.title as teams';
$this->{$this->model}->joins = array('teams' => array('teams.teams_id = users.teams_id', 'inner'));
$this->form_validation->set_rules('firstname', 'firstname', 'trim|required');
$this->form_validation->set_rules('lastname', 'lastname', 'trim');
$this->form_validation->set_rules('sex', 'sex', 'trim');
$this->form_validation->set_rules("image3", 'image3', "trim|callback_image3[$id]");
$this->form_validation->set_rules("email", 'Email', "trim|required|valid_email");
if ($id)
$this->form_validation->set_rules('password', 'Password', 'trim');
else
$this->form_validation->set_rules('password', 'Password', 'trim');
if ($this->form_validation->run() == FALSE)
$this->load->view($this->module . '/manage', $data);
else {
$this->users_model->username = $this->input->post('username');
$this->users_model->email = $this->input->post('email');
$this->users_model->firstname = $this->input->post('firstname');
$this->users_model->lastname = $this->input->post('lastname');
$this->users_model->sex = $this->input->post('sex');
if (strlen($this->input->post('password')) > 0)
$this->{$this->model}->password = md5($this->input->post('password'));
$this->{$this->model}->save();
redirect('member/' . $this->module);
}
}else{
exit('Hacking Attempt: Get out of the system ..!');
}
}
Users_model.php
<?php
class Users_model extends CI_model
{
public $_table = 'users';
public $_primary_keys = array('user_id');
}
を管理したユーザーのコントローラは、他のページにリダイレクトするか、この詳細を編集カントメッセージを与えるよりも、セッションに役割を作成し、(役割==ユーザー)かどうかを確認した場合。 –
MD5はセキュリティ上の理由から壊れていると見なされ、パスワードハッシュには不十分です。 ['password_hash()'](http://us3.php.net/manual/en/function.password-hash.php)と['password_verify()'](http://us3.php.net/ manual/en/function.password-verify.php)を使用してください。 5.5より前のバージョンのPHPを使用している場合は、[この互換性パック](https://github.com/ircmaxell/password_compat)を使用できます。 –