Information registered at the bank is exchanged

Asked

Viewed 24 times

1

I have a form that sends the information to a bank and a page that takes this information and prints it in table format. However, the information in this table is appearing exchanged and when I try to register it in a different way, it appears right, which leads me to believe that the bank is not receiving the information correctly.

Form:

<div class="container">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h1 style="
                    margin-top:100px;">Cadastro de Formações</h1>
                <p> </p>
                <p class="lead"></p>
                <ul class="list-unstyled">
                    <form id="cadastro" name="cadastro" method="post" action="banco/updateF.php" style="
                        text-align: left;
                        margin-top:50px;">
                        <div class="col-lg-12">
                            <div class="form-group" style="
                        text-align: left;">
                                <label  for="NOME">Nome: </label>
                                <input  type="text" required class="form-control" id="NOME" name="NOME" placeholder="Nome da formação">
                             </div>
                        </div>

                        <div class="col-lg-12">
                            <div class="form-group" method="post" style="
                        text-align: left;">
                                <label  for="CARGA">Objetivo: </label>
                                <input  type="text" required class="form-control" id="OBJETIVO" name="CARGA" placeholder="Objetivo da formação">
                             </div>
                        </div>
                        <div class="col-lg-12">
                            <div class="form-group" method="post" style="
                        text-align: left;">
                                <label  for="OBJETIVO">Carga: </label>
                                <input  type="text" required class="form-control" id="CARGA" name="OBJETIVO" placeholder="Carga horária da formação">
                             </div>
                             <div class="form-group" method="post" style="
                        text-align: left;">
                                <label for="CONTEUDO">Conteúdo da programático: </label>
                                <textarea class="form-control" id="CONTEUDO" rows="3" name="CONTEUDO" placeholder="Conteúdo programático da formação"></textarea>
                             </div>
                             <div class="">
                                <button type="submit" class="btn btn-primary btn-lg btn-block">Salvar</button>
                            </div>
                            <div class="alert alert-info" role="alert">
                                <strong>Hey! </strong> Antes de realizar o cadastro, certifique-se de que não se esqueceu de nada! :)
                            </div>
                        </div>
                     </form>
                </ul>
            </div>
        </div> 
    </div>

Connection:

<?php
    $nome = $_POST['NOME'];
    $objetivo = $_POST['OBJETIVO'];
    $carga = $_POST['CARGA'];
    $conteudo = $_POST['CONTEUDO'];

    $strcon = mysqli_connect('localhost','root','', 'db_formacao') or die('Erro ao conectar ao banco de dados');
    $sql = "INSERT INTO formacoes VALUES ('$id', '$nome', '$objetivo', '$carga', '$conteudo')"; 
    mysqli_query($strcon,$sql) or die("Erro ao tentar cadastrar registro");
    mysqli_close($strcon);
    echo '<script type="text/javascript">
            alert("Salvo com Sucesso !");
            window.history.go(-1);
        </script>';
?>

The bank (in phpMyAdmin):

inserir a descrição da imagem aqui

The table:

inserir a descrição da imagem aqui

If you could direct me or point out the mistake, I’d appreciate it. Any changes I update here. :)

1 answer

2


Hello, check the attributes name of their inputs, I believe they are exchanged in CARGA and OBJETIVO.

  • How did I not see this before? That’s exactly what it was!

  • Happens a lot, @Marianaferreira (:

Browser other questions tagged

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