Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Nie wyświetlające się komunikaty
Forum PHP.pl > Forum > Przedszkole
-armind-
Witam, mam pewien problem z którym nie moge sobie poradzić. Jest on dosc banalny ale "jednak" nie potrafie.

Chodzi o te komunikaty wyswietlające się:

  1. if ($this->session->flashdata('data')) : echo '<div class="alert alert-danger">'.$this->session->flashdata('data').'</div>'; endif;
  2.  
  3.  
  4. if ($this->session->flashdata('pass')) : echo '<div class="alert alert-danger">'.$this->session->flashdata('pass').'</div>'; endif;
  5.  



Działa tylko to pierwsze "data" drugie już sie nie wyświetla, prosił bym o pomoc.

[php][ public function edit()
{
if ($this->input->post('profil') ||
$this->input->post('haslo'))
{
$this->load->library('form_validation');
$this->form_validation->set_rules('name', '', 'trim|required|xss_clean');
$this->form_validation->set_rules('dd', '', 'trim|xss_clean');
$this->form_validation->set_rules('mm', '', 'trim|xss_clean');
$this->form_validation->set_rules('yy', '', 'trim|xss_clean');
$this->form_validation->set_rules('city', '', 'trim|xss_clean');
$this->form_validation->set_rules('email', '', 'trim|xss_clean|valid_email');
$this->form_validation->set_rules('gg', '', 'trim|xss_clean');
$this->form_validation->set_rules('music', '', 'trim|xss_clean');
$this->form_validation->set_rules('zainteresowania', '', 'trim|xss_clean');

$this->form_validation->set_rules('day', 'day', 'required|xss_clean');
$this->form_validation->set_rules('month', 'month', 'required|xss_clean');
$this->form_validation->set_rules('year', 'year', 'required|xss_clean');

$this->form_validation->set_rules('pass','Password','trim|required|min_length[4]|max_length[32]');
$this->form_validation->set_rules('pass_c','Reenter Password','trim|required|min_length[4]|max_length[32]|matches[password]');


if($this->input->post('day') == 0 || $this->input->post('month') == 0 || $this->input->post('year') == 0)
{
$this->session->set_flashdata('data', 'Proszę sprawdzić datę urodzin.');
redirect('profile/index');
}



if($this->input->post('pass') != $this->input->post('pass_c'))
{
$this->session->set_flashdata('pass', 'Podane hasła nie są takie same.');
redirect('profile/index');
}


else
{
$id = $this->session->userdata('user_id');
if ($this->input->post('pass') != '' && $this->input->post('pass_c') != '')
{
$data['pass'] = md5($this->input->post('pass'));
}
$data['name'] = $this->input->post('name');
$data['user_dd'] = $this->input->post('day');
$data['user_mm'] = $this->input->post('month');
$data['user_yy'] = $this->input->post('year');
$data['city'] = ($this->input->post('city')!='' ? $this->input->post('city') : NULL) ;
$data['email'] = ($this->input->post('email')!='' ? $this->input->post('email') : NULL) ;
$data['gg'] = $this->input->post('gg');
$data['music'] = ($this->input->post('music')!='' ? $this->input->post('music') : NULL) ;
$data['zainteresowania'] = ($this->input->post('zainteresowania')!='' ? $this->input->post('zainteresowania') : NULL) ;
$this->Profile_model->editUser($data, $id);
redirect('profile/index');
}

}

else
redirect('profile/index');
}/php]
markonix
Używaj prawidłowo znaczników na forum, tak trudno zobaczyć wysłany post po dodaniu?

Błąd logiczny - po redirect nic się więcej nie wykona tak więc skrypt tylko zdążył przypisać jedną zmienną sesyjną. Drugiej w ogóle nie waliduje.
rad11
a pozatym sprawdzasz ten warunek

  1. if($this->input->post('pass') != $this->input->post('pass_c'))
  2. {
  3. $this->session->set_flashdata('pass', 'Podane hasła nie są takie same.');
  4. redirect('profile/index');
  5. }


a przedtem sprawdzasz

  1.  
  2. $this->form_validation->set_rules('pass','Password','trim|required|min_length[4]|max_length[32]');
  3. $this->form_validation->set_rules('pass_c','Reenter Password','trim|required|min_length[4]|max_length[32]|matches[password]');


dwa razy to samo robisz.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.