Remove Mysql record with PHP [closed]

0

I have a PHP page with connection to Mysql. Everything works perfectly, however I have a DELETE button, which when I click it, takes the ID of that entry, goes to a del.php page and should remove this entry in Mysql. However, "it seems" that clicking on delete, nothing happens. If you hover over the delete icon, it returns the ID of each record perfectly. Can anyone help me understand what I'm doing wrong?

Code where you return the data to index.php

 <?php  
    while($row = $stm->fetch())  {




   echo "<tr>"."<td><input type=checkbox name='check[]' value='[]' ></td>"."</td><td>" .$row['ip']. "</td><td>". $row['hostname'] . "</td><td>" . $row['sender'] . "</td><td>" . $row['subject'] . "</td><td>" .$row['quantidade']. " <td><a href=del.php?id=". $row['id'] . " data-placement='top' data-toggle='tooltip' title='Delete'><button class='btn btn-danger btn-xs' data-title='Delete' data-toggle='modal' data-target='#delete' ><span class='glyphicon glyphicon-trash'></span></button></p>
</tr>" .'' ;
}


?>

del.php content

<?php

    // Dados da conexão com o banco de dados
    define('SERVER', 'xxxxx');
    define('DBNAME', 'yyyy');
    define('USER', 'qqqq');
    define('PASSWORD', '');

     if (isset($_GET['id']))
        $id = $_GET['id'];
     else
        $tmpString = null;


$opcoes = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
$conexao = new PDO("mysql:host=".SERVER."; dbname=".DBNAME, USER, PASSWORD, $opcoes);

$sql  = "DELETE FROM spammer WHERE id=".$id;
$stm = $conexao->prepare($sql);
$stm->execute();


?>
    
asked by anonymous 27.02.2017 / 22:45

1 answer

1

I discovered the error. I had a TAG form in my HTML that was generating this problem, I removed it and went live.

I'm closing this question.

    
27.02.2017 / 23:22