-2

当我打开form.php时,我输入了 ID,然后在按钮Enviar上说:Recebeste as moedas。来自 obrigado.php

当我检查我的数据库时,不要添加硬币。

一些错误?在哪里?

表单.php

   <form method="post" action ="obrigado.php">
    <textarea rows="4" cols="50" id="ebur" name="ebur">

    </textarea>
            <input type="submit" value="Enviar" />
    </form>

obrigado.php

<font color="green">Recebeste as moedas.<br>
Atualiza a pagina!</font>
  <?php

    if(isset($_POST['ebur']))
    {
        $ebur = mysql_real_escape_string($_POST['ebur']);
    $con=mysqli_connect("address","user","password","account");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Falha ao receber moedas, informa o administrador com o codigo 445ebmds. " . mysqli_connect_error();
      }

    mysqli_query($con,"UPDATE account SET coins=coins +80 WHERE login = '$ebur'");

    mysqli_close($con);
    }
    ?>
4

2 回答 2

0

根据您的说法,您obrigado.php将始终看到一条绿色消息“Recebeste as moedas。Atualiza a pagina!”,因为这个片段

<font color="green">Recebeste as moedas.<br>
Atualiza a pagina!</font>

没有放在任何条件运算符范围内,例如if.

这很难说,您的 SQL 查询是否已成功执行。您需要检查这里mysqli_query()的NoX 回答的结果,如果执行结果正常,则另外显示一条成功消息。

于 2013-03-07T16:23:09.777 回答
0

您可以通过这种方式检查查询是否有错误

if(!mysqli_query(.....))
{
    echo 'ERROR: '.mysqli_error($con);
}
于 2013-03-07T16:24:15.170 回答