I'm having a little issue with my PHP code. I have a MySQL table which is updated when the user fills form inputs with email, etc. I have a simple submit button. It works fine and the data is updated correctly... at the first time. When the page reloads (after pressing submit the first time) the form is empty again so the user can edit his data if he made a mistake. So I tested it again by filling the inputs again. But this time the browser returns an error 404: page not found. Here is the code:
It's in portuguese but I hope it's no problem for you! This is my view. If you need more details just ask.
<?=form_open(@$formulario, array( 'id' => 'form-blog' ))?>
some form inputs
<button name="salvar" class="btn btn-default btn-primary" type="submit" value="1">Salvar</button>
<?form_close();?>
And the controller is as following:
public function index()
{
@$dados['formulario'] = $this->config->base_url("index.php/configuracao/email/edita");
$this->load->helper('form');
$this->load_view("configuracao/email", $dados);
}
public function edita()
{
$this->load->library('form_validation');
//Se o formulário foi enviado
if($this->input->post('salvar'))
{
form validation...
if ($this->form_validation->run() == TRUE)
{
$arr_dados1 = array('valor' => $this->input->post('emailcontato',TRUE));
$arr_dados2 = array('valor' => $this->input->post('assuntocontato',TRUE));
$arr_dados3 = array('valor' => $this->input->post('emailorcamento',TRUE));
$arr_dados4 = array('valor' => $this->input->post('assuntoorcamento',TRUE));
$this->config_model->atualizar('EmailContato', $arr_dados1);
$this->config_model->atualizar('AssuntoContato', $arr_dados2);
$this->config_model->atualizar('EmailOrcamento', $arr_dados3);
$this->config_model->atualizar('AssuntoOrcamento', $arr_dados4);
}
}
$this->load_view("configuracao/email");
}
So, basically that is my code. Does anyone have any idea why this could be happening?
Thank you in advance!