Double insertion with mssql_query

1

I'm having a little problem and would like help solving it. I have a code that inserts into a SQL SERVER database through php. Everything is fine except that two "INSERT" on the bench are being made. I can not see what is wrong, so I wish someone could help me

The $ dispatch variable is triggered once the form is submitted. I do not even know why this double INSERT: (

if($envio){

$pastaupload = 'candidatos/';
$arquivoupload = $pastaupload .  time() . $_FILES['arquivo']['name'];   

move_uploaded_file($_FILES['arquivo']['tmp_name'], $arquivoupload );
$caminho = "http://meusite.com.br/".$arquivoupload;

$insert ="INSERT INTO CANDIDATO (NOME, DH_NASCIMENTO, CEP, ENDERECO, NUMERO, BAIRRO, MUNICIPIO, UF, TELEFONE, CELULAR, EMAIL, CD_SEGMENTO_CARGO, OBSERVACAO, PATH_CURRICULO, CD_STATUS, CD_USUARIO) VALUES ('$nome', '$datanascimento', '$cep', '$endereco', '$numero', '$bairro', '$cidade', '$uf', '$telefone', '$celular', '$email', $segmento, '$observacoes', '$caminho', 1, 12 )";

mssql_query($insert);

mssql_close($connection); 

}
    
asked by anonymous 23.10.2015 / 19:50

2 answers

1

Verify that the form is not being submitted twice. A good way to do this is to take mssql_query and simply make echo "Test"; or something.

If it does not, try also to use Developer Tools , available in several browsers. Normally there is a way to see submissions made.

    
23.10.2015 / 20:02
2

I discovered what was happening, I was using a function to upload the files, move_uploaded_file() .

It was the one that was causing the record to be entered twice. I just put it inside an if and it worked!

I tested what you suggested, thank you very much for the attention of everyone!

    
26.10.2015 / 13:37