Interaction PHP and Mysql form does not work

Asked

Viewed 89 times

0

Fellas, I’m doing a pro bono job for a public service, and I’ve been trying for days to figure out what’s wrong with my code. If anyone can help me, I really appreciate it.

This is the form:

<html>

<style>

::-webkit-input-placeholder  { color:#CDCDCD; }
input:-moz-placeholder { color:#CDCDCD; }
textarea:-moz-placeholder { color:#CDCDCD; }​

</style>


<form name="saque" action="https://equadsaude.000webhostapp.com/bancodados_atualizar.php" method="POST">

<table>

<tr>
<td>Processo</td>         </tr>

<tr>
<td><input name="n1" placeholder="somente algarismos"></td>
</tr>

<tr>
<td>Valor total sacado</td>   </tr>

<tr>
<td><input name="n4" placeholder="00000.00"></td>
</tr>

<tr>
<td>Observações e Data </td> </tr>

<tr>
<td><input type="text" name="n3" ></td>
</tr>

<tr>
<td col span="3"><input type="submit" name="submit" value="Atualizar"></td>
</tr>
</table>
</form>
</html>

And the file . php (which is on the local server) that he should call is this:

<?php
if (isset($_POST["submit"])) 
{

$conectar = new mysqli("localhost","id1019345_dados_sobras","equadsaude", "id1019345_sobras");
$processo = $_POST[ 'n1' ] ;
$valor_sacado = $_POST[ 'n4' ] ;
$observacoes = $_POST[ 'n3' ] ;

//variavel de teste do POST no banco de dados
$teste = mysqli_query($conectar, "SELECT 'Processo' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");
//variavel para cálculo do Valor da Sobra no banco de dados
$sql_seleciona = mysqli_query($conectar, "SELECT 'Valor_sobra' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");
//variavel para selecao das Observacoes no banco de dados
$sql_seleciona2 = mysqli_query ($conectar, "SELECT 'Observacoes' FROM 'Tab_Index' WHERE 'Processo' = '$processo' ");

if(mysqli_num_rows($conectar, $teste) == 0)
{
echo "<p>Não existe o registro informado. Verifique novamente no Banco de Dados.</p>";  exit(mysqli_error());
}

else
{
$query1 = mysqli_query ($conectar, $sql_seleciona);
$resultado1 = $query1 - $valor_sacado;
$query2 = mysqli_query ($conectar, $sql_seleciona2);
$resultado2 = $query2."/". $observacoes;
                  
}

//Update do banco de dados
$sql_alterar = mysqli_query($conectar, "UPDATE 'Tab_Index' SET 'Valor_sobra' =  '$resultado1', 'Observacoes' =  '$resultado2' WHERE 'Processo' = '$processo' ");

if  ( isset ($sql_alterar) )
{
print "<h3> Valor da sobra atualizado com sucesso </h4>\n" ;
}
else 
{ 
print "<h3> Erro ao atualizar </h4>\n" ;
}

}
  ?>

  • If you are sending the data to another file, why are you opening a condition if (isset($_POST["submit"]))? It is preventing you from allocating variables.

1 answer

0

Dear Danilo, I have tried to remove this condition, and it does not work either. The error that appears is the same:

The equadsaude.000webhostapp.com page is not working

equadsaude.000webhostapp.com is unable to fulfill this request at the moment. HTTP ERROR 500

Browser other questions tagged

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