Jump to content
Fórum Script Brasil
  • 0

Não consigo deletar uma tabela


Brandow

Question

eu estou com problema para deletar as tabelas por meio de um código php, eu aperto em excluir e a tabela não deleta.

códigos:

listar_usuários

<?php
// inclui o arquivo de validar sessão
// inclui o arquivo de configuração do sistema
include "config_sistema.php";

// faz consulta no banco de dados
$consulta = mysql_query("select * from cliques");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-size: 36px}
.style2 {
    color: #000000;
    font-weight: bold;
}
.style3 {
    color: #FFFFFF;
    font-weight: bold;
}
-->
</style>
</head>

<body>
<form action="deletar_usuario.php" method="post" enctype="multipart/form-data">
<table width="732" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="71" height="29"> </td>
    <td width="158"> </td>
    <td width="28"> </td>
    <td width="247"> </td>
    <td width="39"> </td>
    <td width="85"> </td>
    <td width="56"> </td>
    <td width="48"> </td>
  </tr>
  <tr>
    <td height="46"> </td>
    <td> </td>
    <td> </td>
    <td valign="top"><span class="style1">Lista de usuarios</span> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td height="20"> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td height="24"> </td>
    <td> </td>
    <td colspan="3" valign="middle" class="style2">Lista de usuarios | <a href="total_usuarios.php" 

class="style2">Total de cadastros</a> | <span class="style2"><a href="../logout.php" 

class="style2">Logout</a> </span></td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td height="24"></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td valign="top"><label for="Submit"></label>
      <input type="submit" name="deletar" value="deletar" id="deletar" /></td>
    <td></td>
  </tr>
  <tr>
    <td height="2"></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  
  <tr>
    <td height="52"> </td>
    <td colspan="6" valign="top"><table width="100%" border="2" bordercolor="#FFFFFF" cellpadding="0" 

cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="258" height="24" align="center" valign="middle" bgcolor="#000000"><span 

class="style3">Nome:</span></td>
          <td width="278" align="center" valign="middle" bgcolor="#000000" class="style3">Site</td>
          <td width="67" align="center" valign="middle" bgcolor="#000000" class="style3">Excluir</td>
        </tr>
  <?php
while($linhas = mysql_fetch_object($consulta)) {
?>
      <tr>
        <td height="24" align="center" valign="middle" bgcolor="#CCCCCC"><?php echo 

$linhas->Nome;?> </td>
          <td align="center" valign="middle" bgcolor="#CCCCCC"><?php echo $linhas->url;?> </td>
          <td align="center" valign="middle" bgcolor="#CCCCCC" class="style2"><a 

href="deletar_usuario.php?=<?=$linhas->id;?>" class="style2">
            <input name="select" type="checkbox" id="select" value="<?php $linhas->id;?>" />
            <label for="checkbox"></label>
          </a></td>
        </tr>
      
  <?php
}
?>
      
      
      
      
    </table></td>
    <td> </td>
  </tr>
  <tr>
    <td height="136"> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
</form>
</body>
</html>
Deletar_usuário
<?php
include "config_sistema.php";

// recebe os dados do formulario
$codigo = (int) $_POST['id'];

// deleta o usuario
$consulta = mysql_query("delete from cliques where id='$id'");

// verifica se foi excluido o usuario
if($consulta) {
    $msg = urlencode("Usuário excluido com sucesso!");
    header("Location: listar_usuarios.php?msg=$msg");
    exit;
} else {
    $erro = urlencode("Não foi possivel excluir o contato!");
    header("Location: listar_usuarios.php?erro=$erro");
    exit;
}
?>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...