douqiao2008 2015-09-14 23:17
浏览 55

提交表单两次时出错404

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败
    • ¥15 树莓派5怎么用camera module 3啊
    • ¥20 java在应用程序里获取不到扬声器设备
    • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
    • ¥15 Attention is all you need 的代码运行