Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conecta = mysql_connect('localhost','root','') or die(mysql_error());
- $db = mysql_select_db('cadastro') or die(mysql_error());
- ?>
- <!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=utf-8" />
- <title>Exibir Usuarios</title>
- <link href="css/estilo.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <?php if(isset($_POST['acao']) && $_POST['acao'] == 'apagar'){
- $iduser = $_POST['id'];
- $del_imgs = mysql_query("SELECT * FROM usuarios WHERE id = '$iduser'");
- while($lndel = mysql_fetch_array($del_imgs)){
- $file = 'imagens';
- $foto = $lndel['foto'];
- unlink($file.'/'.$foto);
- }
- $deleta = mysql_query("DELETE FROM usuarios WHERE id = '$iduser'");
- if($deleta){
- echo '<script>alert("Usuario deletado");location.href="exibe.php";</script>';
- }else{}
- }
- ?>
- <div id="exibir">
- <table cellpadding="4" cellspacing="3" border="0">
- <tr bgcolor="#ccc">
- <td><strong>Foto</strong></td>
- <td><strong>Nome</strong></td>
- <td><strong>Email</strong></td>
- <td><strong>Cidade</strong></td>
- <td><strong>Endereço</strong></td>
- <td><strong>Estado</strong></td>
- <td><strong>Apagar</strong></td>
- </tr>
- <?php
- $seleciona = mysql_query("SELECT * FROM usuarios ORDER BY id DESC");
- if(@mysql_num_rows($seleciona) == 0){
- echo "Não há usuários cadastrados";
- }
- while($lnuser = mysql_fetch_array($seleciona)){
- $pasta = 'imagens';
- ?>
- <tr bgcolor="#ebebeb">
- <td><img src="<?php echo $pasta.'/'.$lnuser['foto'];?>" width="100" height="80" /></td>
- <td><?php echo $lnuser['nome'];?></td>
- <td><?php echo $lnuser['email'];?></td>
- <td><?php echo $lnuser['cidade'];?></td>
- <td><?php echo $lnuser['endereco'];?></td>
- <td><?php echo $lnuser['estado'];?></td>
- <td>
- <form action="" method="post" enctype="multipart/form-data">
- <input type="hidden" name="id" value="<?php echo $lnuser['id'];?>" />
- <input type="hidden" name="acao" value="apagar" />
- <input type="submit" value="Apagar usuario" />
- </form>
- </td>
- </tr>
- <?php
- }
- ?>
- </table>
- </div><!--exibir-->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment