[eluser]Faitas[/eluser]
Hello, everybody. I'm creating a vote system. But system is running with problems.
Redirect function is incorect in my system. When I get a session user_id and check for it.
I have a form of new message, user is fill all fields of form. When user is fill not all fields of form he is redirecting to control/new_message_view and trying one more time. I'm redirecting this moment, but when I'm redirecting to control/new_message_view, user_id become empty and system redirecting to auth/login.
I have to do this redirect function correct, otherwise my system will be incorect.
Code:
Code:
public function new_message_view()
{
//Gauname visus puslapius
$result = $this->votes_model->get_all_webs();
//Gauname vartotojo duomenis ir laiką
$username = $this->session->userdata("username");
$user_id = $this->session->userdata("user_id");
if(empty($user_id))
{
redirect("login/login_view");
}
//Gauname visus vartotojus iš users lentelės
$all_members = $this->control_model->get_all_users();
$data['title'] = "Nauja žinutė";
$data['content'] = $this->load->view("control/new_message", array('webs_in_system' => $result->num_rows(), 'username' => $username, 'all_members' => $all_members), TRUE);
$this->load->view("template", $data);
}
Code:
public function new_message()
{
if($this->input->post("send"))
{
//Gauname visus puslapius
$result = $this->votes_model->get_all_webs();
//Gauname vartotojo duomenis ir laiką
$username = $this->session->userdata("username");
$user_id = $this->session->userdata("user_id");
$date = date("H") + 3; // 3 valandom date funkcija atsilieka nuo LT laiko
if(empty($user_id))
{
redirect("login/login_view");
}
//Gauname visus įvestus duomenis
$theme = $this->input->post("theme");
$username = $this->input->post("username");
$message = $this->input->post("message");
//Tikrinimo kintamasis
$check = TRUE;
if(empty($theme))
{
$this->messages->add("Turi įvesti temą", "error");
$check = FALSE;
}
if(empty($username))
{
$this->messages->add("Turite pasirinkti vartotojo vardą", "error");
$check = FALSE;
}
if(empty($message))
{
$this->messages->add("Turite parašyti žinutę", "error");
$check = FALSE;
}
if($check == FALSE)
{
$data['title'] = "Nauja žinutė";
$data['content'] = $this->load->view("control/new_message", array('webs_in_system' => $result->num_rows(), 'username' => $username, 'all_members' => $all_members), TRUE);
}
$data['title'] = "Žinutės";
$data['content'] = $this->load->view("control/messages_view", array('webs_in_system' => $result->num_rows(), 'username' => $username, 'date' => $date), TRUE);
$this->load->view("template", $data);
}
}
This is big problem for me. Please, help me.