Welcome Guest, Not a member yet? Register   Sign In
form submit goes to wrong url
#1

[eluser]SPeed_FANat1c[/eluser]
Hi,

I make a form opening:

Code:
echo form_open ('admin_/naujienos/redaguoti/'.$new_id.'/'.$offset);

And when I press submit button it goes to url http://localhost/darzelis/admin_/naujienos0

I checked the source in browser, I have a good <form> tag

Code:
<form action="http://localhost/darzelis/admin_/naujienos/redaguoti/7/0" method="post">

I have only one form in my page. What is happening there? Maybe there is stupid mistake somewhere, I have no idea Sad
#2

[eluser]Bart Mebane[/eluser]
Code:
<form action="http://localhost/darzelis/admin_/naujienos/redaguoti/7/0" method="post">
Do you have a route set for that url?
#3

[eluser]SPeed_FANat1c[/eluser]
No, I have only set route for default controller


Code:
$route['default_controller'] = "home";

Edit:


Found whrere is the problem - it did not like the method 'redaguoti'. I changed to 'redaguoti2' and now it sends to correct url. So I just need another method for submission.

I wanted to generate form and save data with the same method. The method looks like this:

Code:
function redaguoti($new_id,$offset)
  {
      if($this->membership->is_logged_in())
    {
        $this->load->library('form_validation');
        
                  
        $this->form_validation->set_rules('input_pavadinimas', 'Pavadinimas', 'required|max_length[200]');
        
        $this->form_validation->set_rules('text', 'Tekstas', 'required');
        
        $this->form_validation->set_message('required', 'Laukas "%s" turi būti užpildytas');
          
        
        
          if ($this->form_validation->run() == FALSE)
        {
    
            $this->load->helper('form');
            
            
            
            $this->data_header['title'] = 'Administravimas - naujienos redagavimas';
            $this->data_header['javascript'] = '[removed][removed]
                                              [removed][removed]
                                               [removed][removed]';
            $new = $this->News_model->getNew($new_id);
            $this->data_main['new'] = $new;                    
            $this->display('admin/naujienos/redagavimas_view');
            
        }
        else
        {
            
            $data = array(
               'title' => $this->input->post('input_pavadinimas'),
               'new' => stripslashes($_POST['text']),
               'new_ending' => stripslashes($_POST['text_ending']),
               'meta_keywords' => $this->input->post('input_keywords'),
               'meta_description' => $this->input->post('input_description'),
               'rodoma' => TRUE
            );
            $this->db->where('new_id',$new_id)->update('naujienos', $data);
            redirect('admin_/naujienos'.$offset);
        }    
    }
    else redirect('admin/login');
  }

So initialy form_validation->run() will be false, so it generates the form. After we submit, form_validation->run() should be true and save the data.

But I guess I'll have to make another method for submiting data. Just curious, why it cannot work in the way I did?




Theme © iAndrew 2016 - Forum software by © MyBB