Update in the database is not working

-2

My update in the bank does not work, it follows codes:

aluno.php

<form method="post" action="?acao=save&id_aluno=<?php echo $id; ?>">
    <?php echo $pegaid; ?>
    <input type="text" name="ID" class="txt-medium bradius" value="<?php echo $id; ?>"/>
    <input type="text" name="Nome_completo" class="txt-medium bradius" value="<?php echo $full_name; ?>"/>
    <input type="submit" value=" Salvar " class="btn-save-medium" />
</form>

header.php

if($_GET["acao"] == ("save")) {
     $startaction = 6;
}

inserts.php

include 'header.php';

  if($startaction == 6){
    if($acao == "save") {
      $pegaid = $_GET['id_aluno'];
            $pegaidpost = $_POST['ID'];
       $update_full_name = $_POST['Nome_completo'];
              $update_data = "UPDATE alunos SET Nome_completo = '$update_full_name' WHERE ID = '$pegaid'";
        if($update_data) {
          echo"<script> alert('Dados atualizados com sucesso'); </script>";
        } else {
          echo"<script> alert('Dados NÃO atualizados'); </script>";
        }
    }
}

I looked at the field name in my database, it is Nome_completo normal, just as it is in the name="Nome_completo" parameter;

    
asked by anonymous 07.02.2017 / 05:43

3 answers

1

SUGGESTION:

  • First: The ID is an integer value ... Verify that '$pegaid' returns a character or integer value here: "... WHERE ID = '$pegaid'" .

  • Second: Is your connection to BD well-done?

07.02.2017 / 10:42
0

In your code, in addition to not having the code for the connection, mysql_connect there are no the mysql_query that would be responsible for picking up your $update_data variable and passing it as SQL command to your base.

    
07.02.2017 / 10:12
0

Is your connection to the bank at that header.php?

And in this line if($update_data) { should be if(mysql_query($update_data)) {

I hope I have helped:)

    
07.02.2017 / 12:07