Я использовал данные сеанса.Но я хочу сделать sessiondata = что-то на БД.Например,
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<img alt="" src="<?php
if(($this->session->userdata('people_id')) == 'cosId') { echo base_url().'upload/customer/'.$this->session->userdata('people_img');} else{ echo base_url().'upload/user/'.$this->session->userdata('people_img');} ?>">
<span class="username"><?php echo $this->session->userdata('people_name'); ?> <?php echo $this->session->userdata('people_surname'); ?></span>
<b class="caret"></b>
</a>
Как я могу это сделать (($this->session->userdata('people_id')) == 'cosId')
для отображения любого изображения в других каталогах о сессионных данных?
Когда при входе в систему клиент может видеть свою фотографию или когда пользователь при входе может видеть свою фотографиюиз другого каталога / корневого каталога изображений.
Мой контроллер с пользовательскими данными находится ниже:
$username = $this->input->post('username');
$password = $this->input->post('password');
$user_data = $this->db->get_where('user', array('userUsername' =>$username,'userPass' => $password));
$cus_data = $this->db->get_where('customer', array('cosUserName' =>$username,'cosPassword' => $password));
if ($user_data->num_rows() > 0) {
foreach ($user_data->result_array() as $row) {
$this->session->set_userdata('people_id',$row['userId']);
$this->session->set_userdata('people_name',$row['userName']);
$this->session->set_userdata('people_surname',$row['userSurname']);
$this->session->set_userdata('people_usertype',$row['userType']);
$this->session->set_userdata('people_username',$row['userUsername']);
$this->session->set_userdata('people_img',$row['userImg']);
$this->session->set_userdata('people_email',$row['userEmail']);
$this->session->set_userdata('people_status',$row['userStatus']);
$this->session->set_userdata('people_cdate',$row['userDate']);
$this->session->set_userdata('people_department',$row['userDepartment']);
$this->session->set_userdata('people_lang',$row['userLang']);
$this->session->set_userdata("logged_in", true);
}
// redirect to dashboard
redirect("dashboard");
}
elseif ( $cus_data->num_rows() > 0) {
foreach ($cus_data->result_array() as $row) {
$this->session->set_userdata('people_id',$row['cusId']);
$this->session->set_userdata('people_name',$row['cosName']);
$this->session->set_userdata('people_surname',$row['cosSurname']);
$this->session->set_userdata('people_username',$row['cosUserName']);
$this->session->set_userdata('people_img',$row['cosImg']);
$this->session->set_userdata('people_cname',$row['cosCName']);
$this->session->set_userdata('people_country',$row['cosCountry']);
$this->session->set_userdata('people_email',$row['cosEmail']);
$this->session->set_userdata('people_status',$row['cosStatus']);
$this->session->set_userdata('people_lang',$row['cosLang']);
$this->session->set_userdata("logged_in", true);
Могу ли я так редактировать для клиентов?
<?php $cus_data = $this->db->get_where('customer');
foreach ($cus_data->result_array() as $row) {
if($this->session->set_userdata('people_id',$row['cusId']))
{
$src = base_url('upload/customer/'.$this->session->userdata('people_img'));
}
else
{
$src = base_url('upload/user/'.$this->session->userdata('people_img'));
}}
?>
Метод входа в данный момент:
public function index(){
$this->load->library('form_validation');
$this->form_validation->set_rules("username", "Username", "trim|required");
$this->form_validation->set_rules("password", "Password", "trim|required");
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata("error", validation_errors());
$this->load->view("login");
}
else{
$username = $this->input->post('username');
$password = $this->input->post('password');
$user_data = $this->db->get_where('user', array('userUsername' =>$username,'userPass' => $password));
$cus_data = $this->db->get_where('customer', array('cosUserName' =>$username,'cosPassword' => $password));
if ($user_data->num_rows() > 0) {
foreach ($user_data->result_array() as $row) {
$this->session->set_userdata('people_id',$row['userId']);
$this->session->set_userdata('people_name',$row['userName']);
$this->session->set_userdata('people_surname',$row['userSurname']);
$this->session->set_userdata('people_usertype',$row['userType']);
$this->session->set_userdata('people_username',$row['userUsername']);
$this->session->set_userdata('people_img',$row['userImg']);
$this->session->set_userdata('people_email',$row['userEmail']);
$this->session->set_userdata('people_status',$row['userStatus']);
$this->session->set_userdata('people_cdate',$row['userDate']);
$this->session->set_userdata('people_department',$row['userDepartment']);
$this->session->set_userdata('people_lang',$row['userLang']);
$this->session->set_userdata("logged_in", true);
}
// redirect to dashboard
redirect("dashboard");
}
elseif ( $cus_data->num_rows() > 0) {
foreach ($cus_data->result_array() as $row) {
$this->session->set_userdata('people_id',$row['cusId']);
$this->session->set_userdata('people_name',$row['cosName']);
$this->session->set_userdata('people_surname',$row['cosSurname']);
$this->session->set_userdata('people_username',$row['cosUserName']);
$this->session->set_userdata('people_img',$row['cosImg']);
$this->session->set_userdata('people_cname',$row['cosCName']);
$this->session->set_userdata('people_country',$row['cosCountry']);
$this->session->set_userdata('people_email',$row['cosEmail']);
$this->session->set_userdata('people_status',$row['cosStatus']);
$this->session->set_userdata('people_lang',$row['cosLang']);
$this->session->set_userdata("logged_in", true);
}
// redirect to dashboard
redirect("dashboard");
}
else{
$this->session->set_flashdata("error", "Username or Password is invalid");
$this->load->view("login");
}
}
}