Update PHP form data

Asked

Viewed 36 times

0

I would like help to solve the following problem, in the editing part of a form I have fields that are created as "Rows" from the registration part, the registration is correct, however, in the edition I am not able to insert the changes in the respective lines (I believe it applies with something like a matrix).

Imagem Exemplo

Part of the save action

    $regioes_nm = $_POST['nome_regiao'];
    $regioes_cd = $_POST['code_regiao'];

    for ($i = 0; $i < count($regioes_nm); $i++) {

        $cd = $regioes_cd[$i];

        // Grava Região
        $nome_reg = $regioes_nm[$i];        
        $idRegiao = $conexao->consulta("UPDATE proprietario_regiao SET "
                                . " nome = '$nome_reg',"
                                . " data_cadastro = 'CURDATE()'"
                                . "WHERE $bd_ID = '$id'");

        // Grava Gerente
        $nome_ger = $_POST["nome".$cd."_ger"];
        $telefone_ger = $_POST["telefone".$cd."_ger"];
        $email_ger = $_POST["email".$cd."_ger"];
        $senha_ger = $_POST["senha1".$cd."_ger"];
        $ID_Inserido = $conexao->consulta("UPDATE proprietario_gerente SET "
                                ." idRegiao = $idRegiao,"
                                ." nome = '$nome_ger',"
                                ." telefone = '$telefone_ger',"
                                ." email = '$email_ger',"
                                ." senha = '".base64_encode($senha_ger)."',"
                                ." data_cadastro = 'CURDATE()'"
                                ."WHERE $bd_ID = '$id'"); 

        // Grava Técnico
        $nome_tec = $_POST["nome".$cd."_tec"];
        $telefone_tec = $_POST["telefone".$cd."_tec"];
        $email_tec = $_POST["email".$cd."_tec"];
        $senha_tec = $_POST["senha1".$cd."_tec"];
        for ($j = 0; $j < count($nome_tec); $j++) {
            $ID_Inserido = $conexao->consulta("UPDATE proprietario_tecnico SET "
                                ." idRegiao = $idRegiao,"
                                ." nome = '$nome_tec[$j]',"
                                ." telefone = '$telefone_tec[$j]',"
                                ." email = '$email_tec[$j]',"
                                ." senha = '".base64_encode($senha_tec[$j])."',"
                                ." data_cadastro = 'CURDATE()'"
                                ."WHERE $bd_ID = '$id'");  
        }
    }

}
  • I don’t understand how you’re editing the form. I understand that you are listing users row by row, and their data in editable input fields. but which link from Submit to update?

  • That’s exactly it, well the links are these: <button type="submit" class="action-bullet" value="" name="Sair"><div class="action-save-quit"></div><span><?=TXT_BOTAO_EDITAR_E_SAIR?></span></button> <button type="submit" class="action-bullet" value=""><div class="action-save"></div><span><?=TXT_BOTAO_EDITAR?></span></button>

  • But is the button in the print? Is there an error? .

  • No, it is not in the print, what I return is this: $connected->disconnect (); $_SESSION['msg'] = "ok|". TXT_ACAO_RETORNO_EDICAO; if ($_POST['opgrava']=='Quit') { header("Location: ../.../.home.php?area=".$sis_Nome_mP."_manage"); } Else { header("Location: ../../.home.php?area=".$sis_Nome_mP."_editar&id=$id"); } die();

  • With ajax I could use what?

  • Incidentally easier to use ajax is to create a form in each row and the Submit button would send the data to the update page.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.